comparison main/PreferencesDialog.cpp @ 1459:9a3684f1393b 3.0-integration

Try to handle audio device selection more sensibly in cases where only one audio implementation is compiled in
author Chris Cannam
date Tue, 03 Jan 2017 13:30:47 +0000
parents 11484141d969
children f5c828d1f3e2
comparison
equal deleted inserted replaced
1458:96057b1185cb 1459:9a3684f1393b
218 218
219 m_audioRecordDeviceCombo = new QComboBox; 219 m_audioRecordDeviceCombo = new QComboBox;
220 connect(m_audioRecordDeviceCombo, SIGNAL(currentIndexChanged(int)), 220 connect(m_audioRecordDeviceCombo, SIGNAL(currentIndexChanged(int)),
221 this, SLOT(audioRecordDeviceChanged(int))); 221 this, SLOT(audioRecordDeviceChanged(int)));
222 222
223 vector<string> names = breakfastquay::AudioFactory::getImplementationNames(); 223 vector<string> implementationNames =
224 breakfastquay::AudioFactory::getImplementationNames();
225
224 QString implementationName = settings.value("audio-target", "").toString(); 226 QString implementationName = settings.value("audio-target", "").toString();
225 if (implementationName == "auto") implementationName = ""; 227 if (implementationName == "auto") implementationName = "";
228 if (implementationName == "" && implementationNames.size() == 1) {
229 // We won't be showing the implementations menu in this case
230 implementationName = implementationNames[0].c_str();
231 }
232
226 audioImplementation->addItem(tr("(auto)")); 233 audioImplementation->addItem(tr("(auto)"));
227 m_audioImplementation = 0; 234 m_audioImplementation = 0;
228 for (int i = 0; in_range_for(names, i); ++i) { 235
236 for (int i = 0; in_range_for(implementationNames, i); ++i) {
229 audioImplementation->addItem 237 audioImplementation->addItem
230 (breakfastquay::AudioFactory::getImplementationDescription(names[i]). 238 (breakfastquay::AudioFactory::getImplementationDescription
231 c_str()); 239 (implementationNames[i]).c_str());
232 if (implementationName.toStdString() == names[i]) { 240 if (implementationName.toStdString() == implementationNames[i]) {
233 audioImplementation->setCurrentIndex(i+1); 241 audioImplementation->setCurrentIndex(i+1);
234 m_audioImplementation = i+1; 242 m_audioImplementation = i+1;
235 } 243 }
236 } 244 }
245
237 settings.endGroup(); 246 settings.endGroup();
238 247
239 rebuildDeviceCombos(); 248 rebuildDeviceCombos();
240 m_audioDeviceChanged = false; // the rebuild will have changed this 249 m_audioDeviceChanged = false; // the rebuild will have changed this
241 250
535 frame = new QFrame; 544 frame = new QFrame;
536 subgrid = new QGridLayout; 545 subgrid = new QGridLayout;
537 frame->setLayout(subgrid); 546 frame->setLayout(subgrid);
538 row = 0; 547 row = 0;
539 548
540 subgrid->addWidget(new QLabel(tr("Audio service:")), row, 0); 549 if (implementationNames.size() > 1) {
541 subgrid->addWidget(audioImplementation, row++, 1, 1, 2); 550 subgrid->addWidget(new QLabel(tr("Audio service:")), row, 0);
551 subgrid->addWidget(audioImplementation, row++, 1, 1, 2);
552 }
542 553
543 subgrid->addWidget(new QLabel(tr("Audio playback device:")), row, 0); 554 subgrid->addWidget(new QLabel(tr("Audio playback device:")), row, 0);
544 subgrid->addWidget(m_audioPlaybackDeviceCombo, row++, 1, 1, 2); 555 subgrid->addWidget(m_audioPlaybackDeviceCombo, row++, 1, 1, 2);
545 556
546 subgrid->addWidget(new QLabel(tr("Audio record device:")), row, 0); 557 subgrid->addWidget(new QLabel(tr("Audio record device:")), row, 0);
619 QSettings settings; 630 QSettings settings;
620 settings.beginGroup("Preferences"); 631 settings.beginGroup("Preferences");
621 632
622 vector<string> names = breakfastquay::AudioFactory::getImplementationNames(); 633 vector<string> names = breakfastquay::AudioFactory::getImplementationNames();
623 string implementationName; 634 string implementationName;
635
624 if (in_range_for(names, m_audioImplementation-1)) { 636 if (in_range_for(names, m_audioImplementation-1)) {
625 implementationName = names[m_audioImplementation-1]; 637 implementationName = names[m_audioImplementation-1];
626 } 638 }
627 639
628 QString suffix; 640 QString suffix;