MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / checkAndUpdateDeviceList

Function checkAndUpdateDeviceList

app/src/IO/Drivers/Audio.cpp:165–199  ·  view source on GitHub ↗

* @brief Checks for changes in the audio device list and updates it if necessary. */

Source from the content-addressed store, hash-verified

163 * @brief Checks for changes in the audio device list and updates it if necessary.
164 */
165static 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.

Callers 1

refreshAudioDevicesMethod · 0.85

Calls 5

deviceListsDifferFunction · 0.85
replaceDeviceListFunction · 0.85
deviceIndexByIdFunction · 0.85
disconnectDeviceMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected