# HG changeset patch # User Chris Cannam # Date 1481557533 0 # Node ID a89ca5ccb95865e19c5b53ce766fb532f96306fb # Parent f724d092be7ba13e999eb8aa9020ef813296f7cd Reopen the audio device directly when preference is changed diff -r f724d092be7b -r a89ca5ccb958 .hgsubstate --- 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 diff -r f724d092be7b -r a89ca5ccb958 main/MainWindow.cpp --- 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 diff -r f724d092be7b -r a89ca5ccb958 main/PreferencesDialog.cpp --- 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("Restart required

One or more of the application preferences you have changed may not take full effect until Sonic Visualiser is restarted.

Please exit and restart the application now if you want these changes to take effect immediately.

")); m_changesOnRestart = false; } + + if (m_audioDeviceChanged) { + emit audioDeviceChanged(); + } } void diff -r f724d092be7b -r a89ca5ccb958 main/PreferencesDialog.h --- 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; };