# HG changeset patch # User Chris Cannam # Date 1483450247 0 # Node ID 9a3684f1393b07cd49f878c958de04a2eb989711 # Parent 96057b1185cb0e432eae9179f24d1362aa41d288 Try to handle audio device selection more sensibly in cases where only one audio implementation is compiled in diff -r 96057b1185cb -r 9a3684f1393b main/PreferencesDialog.cpp --- a/main/PreferencesDialog.cpp Tue Jan 03 13:05:02 2017 +0000 +++ b/main/PreferencesDialog.cpp Tue Jan 03 13:30:47 2017 +0000 @@ -220,20 +220,29 @@ connect(m_audioRecordDeviceCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(audioRecordDeviceChanged(int))); - vector names = breakfastquay::AudioFactory::getImplementationNames(); + vector implementationNames = + breakfastquay::AudioFactory::getImplementationNames(); + QString implementationName = settings.value("audio-target", "").toString(); if (implementationName == "auto") implementationName = ""; + if (implementationName == "" && implementationNames.size() == 1) { + // We won't be showing the implementations menu in this case + implementationName = implementationNames[0].c_str(); + } + audioImplementation->addItem(tr("(auto)")); m_audioImplementation = 0; - for (int i = 0; in_range_for(names, i); ++i) { + + for (int i = 0; in_range_for(implementationNames, i); ++i) { audioImplementation->addItem - (breakfastquay::AudioFactory::getImplementationDescription(names[i]). - c_str()); - if (implementationName.toStdString() == names[i]) { + (breakfastquay::AudioFactory::getImplementationDescription + (implementationNames[i]).c_str()); + if (implementationName.toStdString() == implementationNames[i]) { audioImplementation->setCurrentIndex(i+1); m_audioImplementation = i+1; } } + settings.endGroup(); rebuildDeviceCombos(); @@ -537,8 +546,10 @@ frame->setLayout(subgrid); row = 0; - subgrid->addWidget(new QLabel(tr("Audio service:")), row, 0); - subgrid->addWidget(audioImplementation, row++, 1, 1, 2); + if (implementationNames.size() > 1) { + subgrid->addWidget(new QLabel(tr("Audio service:")), row, 0); + subgrid->addWidget(audioImplementation, row++, 1, 1, 2); + } subgrid->addWidget(new QLabel(tr("Audio playback device:")), row, 0); subgrid->addWidget(m_audioPlaybackDeviceCombo, row++, 1, 1, 2); @@ -621,6 +632,7 @@ vector names = breakfastquay::AudioFactory::getImplementationNames(); string implementationName; + if (in_range_for(names, m_audioImplementation-1)) { implementationName = names[m_audioImplementation-1]; }