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

Method FillHostDevices

src/toolbars/DeviceToolBar.cpp:436–517  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

434}
435
436void DeviceToolBar::FillHostDevices()
437{
438 const std::vector<DeviceSourceMap> &inMaps = DeviceManager::Instance()->GetInputDeviceMaps();
439 const std::vector<DeviceSourceMap> &outMaps = DeviceManager::Instance()->GetOutputDeviceMaps();
440
441 //read what is in the prefs
442 auto host = AudioIOHost.Read();
443 int foundHostIndex = -1;
444
445 // if the host is not in the hosts combo then we rescanned.
446 // set it to blank so we search for another host.
447 if (mHost->FindString(host) == wxNOT_FOUND) {
448 host = wxT("");
449 }
450
451 for (auto & device : outMaps) {
452 if (device.hostString == host) {
453 foundHostIndex = device.hostIndex;
454 break;
455 }
456 }
457
458 if (foundHostIndex == -1) {
459 for (auto & device : inMaps) {
460 if (device.hostString == host) {
461 foundHostIndex = device.hostIndex;
462 break;
463 }
464 }
465 }
466
467 // If no host was found based on the prefs device host, load the first available one
468 if (foundHostIndex == -1) {
469 if (outMaps.size()) {
470 foundHostIndex = outMaps[0].hostIndex;
471 }
472 else if (inMaps.size()) {
473 foundHostIndex = inMaps[0].hostIndex;
474 }
475 }
476
477 // Make sure in/out are clear in case no host was found
478 mInput->Clear();
479 mOutput->Clear();
480
481 // If we still have no host it means no devices, in which case do nothing.
482 if (foundHostIndex == -1) {
483 return;
484 }
485
486 // Repopulate the Input/Output device list available to the user
487 for (auto & device : inMaps) {
488 if (foundHostIndex == device.hostIndex) {
489 mInput->Append(MakeDeviceSourceString(&device));
490 if (host.empty()) {
491 host = device.hostString;
492 AudioIOHost.Write(host);
493 mHost->SetStringSelection(host);

Callers

nothing calls this directly

Calls 12

MakeDeviceSourceStringFunction · 0.85
wxSizeClass · 0.70
InstanceClass · 0.50
ReadMethod · 0.45
sizeMethod · 0.45
ClearMethod · 0.45
AppendMethod · 0.45
emptyMethod · 0.45
WriteMethod · 0.45
EnableMethod · 0.45
GetCountMethod · 0.45
FlushMethod · 0.45

Tested by

no test coverage detected