MCPcopy Create free account
hub / github.com/audacity/audacity / UpdatePrefs

Method UpdatePrefs

src/toolbars/DeviceToolBar.cpp:248–344  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

246}
247
248void DeviceToolBar::UpdatePrefs()
249{
250 wxString desc;
251 const std::vector<DeviceSourceMap> &inMaps = DeviceManager::Instance()->GetInputDeviceMaps();
252 const std::vector<DeviceSourceMap> &outMaps = DeviceManager::Instance()->GetOutputDeviceMaps();
253
254
255 int hostSelectionIndex = mHost->GetSelection();
256 wxString oldHost = hostSelectionIndex >= 0 ? mHost->GetString(hostSelectionIndex) :
257 wxString{};
258 auto hostName = AudioIOHost.Read();
259
260 // if the prefs host name doesn't match the one displayed, it changed
261 // in another project's DeviceToolBar, so we need to repopulate everything.
262 if (oldHost != hostName)
263 FillHostDevices();
264
265 auto devName = AudioIORecordingDevice.Read();
266 auto sourceName = AudioIORecordingSource.Read();
267 if (sourceName.empty())
268 desc = devName;
269 else
270 desc = devName + wxT(": ") + sourceName;
271
272 if (mInput->GetStringSelection() != desc &&
273 mInput->FindString(desc) != wxNOT_FOUND) {
274 mInput->SetStringSelection(desc);
275 FillInputChannels();
276 } else if (mInput->GetStringSelection() != desc && mInput->GetCount()) {
277 for (size_t i = 0; i < inMaps.size(); i++) {
278 if (inMaps[i].hostString == hostName &&
279 MakeDeviceSourceString(&inMaps[i]) == mInput->GetString(0)) {
280 // use the default. It should exist but check just in case, falling back on the 0 index.
281 DeviceSourceMap *defaultMap = DeviceManager::Instance()->GetDefaultInputDevice(inMaps[i].hostIndex);
282 if (defaultMap) {
283 mInput->SetStringSelection(MakeDeviceSourceString(defaultMap));
284 SetDevices(defaultMap, NULL);
285 } else {
286 //use the first item (0th index) if we have no familiar devices
287 mInput->SetSelection(0);
288 SetDevices(&inMaps[i], NULL);
289 }
290 break;
291 }
292 }
293 }
294
295 devName = AudioIOPlaybackDevice.Read();
296 sourceName = AudioIOPlaybackSource.Read();
297 if (sourceName.empty())
298 desc = devName;
299 else
300 desc = devName + wxT(": ") + sourceName;
301
302 if (mOutput->GetStringSelection() != desc &&
303 mOutput->FindString(desc) != wxNOT_FOUND) {
304 mOutput->SetStringSelection(desc);
305 } else if (mOutput->GetStringSelection() != desc &&

Callers

nothing calls this directly

Calls 12

MakeDeviceSourceStringFunction · 0.85
GetDefaultInputDeviceMethod · 0.80
InstanceClass · 0.50
GetSelectionMethod · 0.45
GetStringMethod · 0.45
ReadMethod · 0.45
emptyMethod · 0.45
GetCountMethod · 0.45
sizeMethod · 0.45
SetSelectionMethod · 0.45
ReadWithDefaultMethod · 0.45

Tested by

no test coverage detected