changeset 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 96057b1185cb
children 8ca62b402846 0a145f215a45
files main/PreferencesDialog.cpp
diffstat 1 files changed, 19 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- 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<string> names = breakfastquay::AudioFactory::getImplementationNames();
+    vector<string> 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<string> names = breakfastquay::AudioFactory::getImplementationNames();
     string implementationName;
+    
     if (in_range_for(names, m_audioImplementation-1)) {
         implementationName = names[m_audioImplementation-1];
     }