changeset 540:0d5c3abc9658 3.0-integration

Delete audio I/O objects in a fixed order
author Chris Cannam
date Wed, 30 Nov 2016 11:44:40 +0000
parents 630c4a9885ca
children fb675409297a 167d37937436
files audio/AudioCallbackPlaySource.cpp framework/MainWindowBase.cpp
diffstat 2 files changed, 18 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/audio/AudioCallbackPlaySource.cpp	Fri Nov 25 10:08:52 2016 +0000
+++ b/audio/AudioCallbackPlaySource.cpp	Wed Nov 30 11:44:40 2016 +0000
@@ -414,6 +414,8 @@
 void
 AudioCallbackPlaySource::play(sv_frame_t startFrame)
 {
+    if (!m_target) return;
+    
     if (!m_sourceSampleRate) {
         cerr << "AudioCallbackPlaySource::play: No source sample rate available, not playing" << endl;
         return;
--- a/framework/MainWindowBase.cpp	Fri Nov 25 10:08:52 2016 +0000
+++ b/framework/MainWindowBase.cpp	Wed Nov 30 11:44:40 2016 +0000
@@ -287,10 +287,25 @@
 MainWindowBase::~MainWindowBase()
 {
     SVDEBUG << "MainWindowBase::~MainWindowBase" << endl;
+
+    // We have to delete the breakfastquay::SystemPlaybackTarget or
+    // breakfastquay::SystemAudioIO object (whichever we have -- it
+    // 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;
+
+    // Then delete the Application objects.
     delete m_playSource;
-    delete m_audioIO;
     delete m_recordTarget;
+    
     delete m_viewManager;
     delete m_oscQueue;
     delete m_oscQueueStarter;