* @brief Refreshes the list of available audio input/output devices. */
| 1169 | * @brief Refreshes the list of available audio input/output devices. |
| 1170 | */ |
| 1171 | void IO::Drivers::Audio::refreshAudioDevices() |
| 1172 | { |
| 1173 | if (!m_init) |
| 1174 | return; |
| 1175 | |
| 1176 | ma_uint32 inputCount = 0; |
| 1177 | ma_uint32 outputCount = 0; |
| 1178 | ma_device_info* inputDevices = nullptr; |
| 1179 | ma_device_info* outputDevices = nullptr; |
| 1180 | // clang-format off |
| 1181 | auto result = ma_context_get_devices(&m_context, |
| 1182 | &outputDevices, |
| 1183 | &outputCount, |
| 1184 | &inputDevices, |
| 1185 | &inputCount); |
| 1186 | |
| 1187 | if (result != MA_SUCCESS) |
| 1188 | return; |
| 1189 | |
| 1190 | // clang-format on |
| 1191 | |
| 1192 | // clang-format off |
| 1193 | const QVector<ma_device_info> newInputDevices(inputDevices, inputDevices + inputCount); |
| 1194 | const QVector<ma_device_info> newOutputDevices(outputDevices, outputDevices + outputCount); |
| 1195 | // clang-format on |
| 1196 | |
| 1197 | checkAndUpdateDeviceList( |
| 1198 | &m_context, |
| 1199 | ma_device_type_capture, |
| 1200 | m_inputDevices, |
| 1201 | newInputDevices, |
| 1202 | m_selectedInputDevice, |
| 1203 | m_isOpen, |
| 1204 | [this] { Q_EMIT inputSettingsChanged(); }, |
| 1205 | [this] { Q_EMIT configurationChanged(); }, |
| 1206 | m_inputCapabilities); |
| 1207 | |
| 1208 | checkAndUpdateDeviceList( |
| 1209 | &m_context, |
| 1210 | ma_device_type_playback, |
| 1211 | m_outputDevices, |
| 1212 | newOutputDevices, |
| 1213 | m_selectedOutputDevice, |
| 1214 | m_isOpen, |
| 1215 | [this] { Q_EMIT outputSettingsChanged(); }, |
| 1216 | [this] { Q_EMIT configurationChanged(); }, |
| 1217 | m_outputCapabilities); |
| 1218 | |
| 1219 | if (m_selectedInputDevice < 0 && newInputDevices.count() > 0) { |
| 1220 | m_selectedInputDevice = 0; |
| 1221 | m_selectedSampleRate = -1; |
| 1222 | m_selectedInputSampleFormat = -1; |
| 1223 | m_selectedInputChannelConfiguration = -1; |
| 1224 | syncInputParameters(); |
| 1225 | configureInput(); |
| 1226 | } |
| 1227 | |
| 1228 | if (m_selectedOutputDevice < 0 && newOutputDevices.count() > 0) { |
nothing calls this directly
no test coverage detected