changeset 556:21e3aab6e3e7 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 2683a8ca36ea
children 7759c2dca846
files framework/MainWindowBase.cpp framework/MainWindowBase.h
diffstat 2 files changed, 27 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/framework/MainWindowBase.cpp	Fri Dec 09 19:04:33 2016 +0000
+++ b/framework/MainWindowBase.cpp	Mon Dec 12 15:45:33 2016 +0000
@@ -295,14 +295,8 @@
     // depends on whether we handle recording or not) before we delete
     // the ApplicationPlaybackSource and ApplicationRecordTarget that
     // they refer to.
-    
-    // First prevent this trying to call target.
-    if (m_playSource) m_playSource->setSystemPlaybackTarget(0);
-
-    // Then delete the breakfastquay::System object.
-    // Only one of these two exists!
-    delete m_audioIO;
-    delete m_playTarget;
+
+    deleteAudioIO();
 
     // Then delete the Application objects.
     delete m_resamplerWrapper;
@@ -2375,6 +2369,28 @@
     }
 }
 
+void
+MainWindowBase::deleteAudioIO()
+{
+    // First prevent this trying to call target.
+    if (m_playSource) m_playSource->setSystemPlaybackTarget(0);
+
+    // Then delete the breakfastquay::System object.
+    // Only one of these two exists!
+    delete m_audioIO;
+    delete m_playTarget;
+
+    m_audioIO = 0;
+    m_playTarget = 0;
+}
+
+void
+MainWindowBase::recreateAudioIO()
+{
+    deleteAudioIO();
+    createAudioIO();
+}
+
 WaveFileModel *
 MainWindowBase::getMainModel()
 {
--- a/framework/MainWindowBase.h	Fri Dec 09 19:04:33 2016 +0000
+++ b/framework/MainWindowBase.h	Mon Dec 12 15:45:33 2016 +0000
@@ -198,6 +198,7 @@
 public slots:
     virtual void preferenceChanged(PropertyContainer::PropertyName);
     virtual void resizeConstrained(QSize);
+    virtual void recreateAudioIO();
 
 protected slots:
     virtual void zoomIn();
@@ -464,6 +465,8 @@
     virtual void setDefaultSessionTemplate(QString);
 
     virtual void createAudioIO();
+    virtual void deleteAudioIO();
+    
     virtual void openHelpUrl(QString url);
     virtual void openLocalFolder(QString path);