changeset 1413:a89ca5ccb958 3.0-integration

Reopen the audio device directly when preference is changed
author Chris Cannam
date Mon, 12 Dec 2016 15:45:33 +0000
parents f724d092be7b
children 65d34b07de85
files .hgsubstate main/MainWindow.cpp main/PreferencesDialog.cpp main/PreferencesDialog.h
diffstat 4 files changed, 17 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/.hgsubstate	Mon Dec 12 09:13:44 2016 +0000
+++ b/.hgsubstate	Mon Dec 12 15:45:33 2016 +0000
@@ -7,7 +7,7 @@
 c37b5598a4beb570417716e30aa649c78312169f icons/scalable
 3257ddb6fff110cc88f3ffeaeefa0f29d5eb3b6f piper-cpp
 5f67a29f0fc7f1b908f7cde4866173a7af337862 sv-dependency-builds
-2683a8ca36ea55b90917713571b9cef6cc049b5f svapp
+21e3aab6e3e7395766025089630b89ec6479ff5a svapp
 4dbb7a7c9c2898c31dac32d5e54cbb92daaf1665 svcore
 6605984fa98f40534b2706555979a16592733850 svgui
 0eebd22a081a824067bf3d5de65326696feab653 vamp-plugin-sdk
--- a/main/MainWindow.cpp	Mon Dec 12 09:13:44 2016 +0000
+++ b/main/MainWindow.cpp	Mon Dec 12 15:45:33 2016 +0000
@@ -4592,6 +4592,9 @@
 
     m_preferencesDialog = new PreferencesDialog(this);
 
+    connect(m_preferencesDialog, SIGNAL(audioDeviceChanged()),
+            this, SLOT(recreateAudioIO()));
+    
     // DeleteOnClose is safe here, because m_preferencesDialog is a
     // QPointer that will be zeroed when the dialog is deleted.  We
     // use it in preference to leaving the dialog lying around because
--- a/main/PreferencesDialog.cpp	Mon Dec 12 09:13:44 2016 +0000
+++ b/main/PreferencesDialog.cpp	Mon Dec 12 15:45:33 2016 +0000
@@ -53,6 +53,7 @@
     m_audioImplementation(0),
     m_audioPlaybackDevice(0),
     m_audioRecordDevice(0),
+    m_audioDeviceChanged(false),
     m_changesOnRestart(false)
 {
     setWindowTitle(tr("Sonic Visualiser: Application Preferences"));
@@ -219,7 +220,7 @@
     settings.endGroup();
 
     rebuildDeviceCombos();
-    m_changesOnRestart = false; // the rebuild will have changed this
+    m_audioDeviceChanged = false; // the rebuild will have changed this
 
     QCheckBox *resampleOnLoad = new QCheckBox;
     m_resampleOnLoad = prefs->getResampleOnLoad();
@@ -695,7 +696,7 @@
         m_audioImplementation = s;
         rebuildDeviceCombos();
         m_applyButton->setEnabled(true);
-        m_changesOnRestart = true;
+        m_audioDeviceChanged = true;
     }
 }
 
@@ -705,7 +706,7 @@
     if (m_audioPlaybackDevice != s) {
         m_audioPlaybackDevice = s;
         m_applyButton->setEnabled(true);
-        m_changesOnRestart = true;
+        m_audioDeviceChanged = true;
     }
 }
 
@@ -715,7 +716,7 @@
     if (m_audioRecordDevice != s) {
         m_audioRecordDevice = s;
         m_applyButton->setEnabled(true);
-        m_changesOnRestart = true;
+        m_audioDeviceChanged = true;
     }
 }
 
@@ -918,6 +919,10 @@
                                  tr("<b>Restart required</b><p>One or more of the application preferences you have changed may not take full effect until Sonic Visualiser is restarted.</p><p>Please exit and restart the application now if you want these changes to take effect immediately.</p>"));
         m_changesOnRestart = false;
     }
+
+    if (m_audioDeviceChanged) {
+        emit audioDeviceChanged();
+    }
 }    
 
 void
--- a/main/PreferencesDialog.h	Mon Dec 12 09:13:44 2016 +0000
+++ b/main/PreferencesDialog.h	Mon Dec 12 15:45:33 2016 +0000
@@ -43,6 +43,9 @@
     };
     void switchToTab(Tab tab);
 
+signals:
+    void audioDeviceChanged();
+                             
 public slots:
     void applicationClosing(bool quickly);
 
@@ -122,6 +125,7 @@
     int m_viewFontSize;
     bool m_showSplash;
 
+    bool m_audioDeviceChanged;
     bool m_changesOnRestart;
 };