diff framework/MainWindowBase.cpp @ 559:7b115a6505b8 3.0-integration

Handle increases in the overall channel count by closing and reopening the audio device.
author Chris Cannam
date Tue, 13 Dec 2016 12:03:48 +0000
parents 7759c2dca846
children 1cc23cee4ebf 58354f2934ec
line wrap: on
line diff
--- a/framework/MainWindowBase.cpp	Mon Dec 12 17:15:24 2016 +0000
+++ b/framework/MainWindowBase.cpp	Tue Dec 13 12:03:48 2016 +0000
@@ -242,6 +242,8 @@
 
     connect(m_playSource, SIGNAL(sampleRateMismatch(sv_samplerate_t, sv_samplerate_t, bool)),
 	    this,           SLOT(sampleRateMismatch(sv_samplerate_t, sv_samplerate_t, bool)));
+    connect(m_playSource, SIGNAL(channelCountIncreased()),
+            this,           SLOT(recreateAudioIO()));
     connect(m_playSource, SIGNAL(audioOverloadPluginDisabled()),
             this,           SLOT(audioOverloadPluginDisabled()));
     connect(m_playSource, SIGNAL(audioTimeStretchMultiChannelDisabled()),
@@ -299,7 +301,6 @@
     deleteAudioIO();
 
     // Then delete the Application objects.
-    delete m_resamplerWrapper;
     delete m_playSource;
     delete m_recordTarget;
     
@@ -2373,15 +2374,24 @@
 MainWindowBase::deleteAudioIO()
 {
     // First prevent this trying to call target.
-    if (m_playSource) m_playSource->setSystemPlaybackTarget(0);
+    if (m_playSource) {
+        m_playSource->setSystemPlaybackTarget(0);
+        m_playSource->setResamplerWrapper(0);
+    }
 
     // Then delete the breakfastquay::System object.
     // Only one of these two exists!
     delete m_audioIO;
     delete m_playTarget;
 
+    // And the breakfastquay resampler wrapper. We need to
+    // delete/recreate this if the channel count changes, which is one
+    // of the use cases for recreateAudioIO() calling this
+    delete m_resamplerWrapper;
+
     m_audioIO = 0;
     m_playTarget = 0;
+    m_resamplerWrapper = 0;
 }
 
 void