* @brief Checks for changes in the audio device list and updates it if necessary. */
| 163 | * @brief Checks for changes in the audio device list and updates it if necessary. |
| 164 | */ |
| 165 | static bool checkAndUpdateDeviceList(ma_context* context, |
| 166 | ma_device_type type, |
| 167 | QVector<ma_device_info>& currentList, |
| 168 | const QVector<ma_device_info>& newList, |
| 169 | int& selectedIndex, |
| 170 | bool isOpen, |
| 171 | const std::function<void()>& settingsChanged, |
| 172 | const std::function<void()>& configurationChanged, |
| 173 | QVector<IO::Drivers::Audio::AudioDeviceInfo>& capabilities) |
| 174 | { |
| 175 | if (!isOpen) { |
| 176 | if (deviceListsDiffer(newList, currentList)) { |
| 177 | replaceDeviceList(context, type, currentList, newList, selectedIndex, capabilities); |
| 178 | settingsChanged(); |
| 179 | configurationChanged(); |
| 180 | return true; |
| 181 | } |
| 182 | |
| 183 | return false; |
| 184 | } |
| 185 | |
| 186 | bool stillConnected = false; |
| 187 | if (selectedIndex >= 0 && selectedIndex < currentList.size()) |
| 188 | stillConnected = deviceIndexById(newList, currentList[selectedIndex].id) >= 0; |
| 189 | |
| 190 | if (!stillConnected) { |
| 191 | IO::ConnectionManager::instance().disconnectDevice(); |
| 192 | replaceDeviceList(context, type, currentList, newList, selectedIndex, capabilities); |
| 193 | settingsChanged(); |
| 194 | configurationChanged(); |
| 195 | return true; |
| 196 | } |
| 197 | |
| 198 | return false; |
| 199 | } |
| 200 | |
| 201 | /** |
| 202 | * @brief Packs a single CSV sample into native bytes for the given ma_format. |
no test coverage detected