changeset 509:7cf6f5501212 tony-2.0-integration

Trim suspend/resume calls
author Chris Cannam
date Wed, 14 Oct 2015 16:02:09 +0100
parents b84d9b512dbd
children 83c60632bac0
files audio/AudioCallbackPlaySource.cpp framework/MainWindowBase.cpp
diffstat 2 files changed, 4 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/audio/AudioCallbackPlaySource.cpp	Wed Oct 14 15:08:55 2015 +0100
+++ b/audio/AudioCallbackPlaySource.cpp	Wed Oct 14 16:02:09 2015 +0100
@@ -414,8 +414,6 @@
 void
 AudioCallbackPlaySource::play(sv_frame_t startFrame)
 {
-    if (m_target) m_target->resume();
-    
     if (!m_sourceSampleRate) {
         cerr << "AudioCallbackPlaySource::play: No source sample rate available, not playing" << endl;
         return;
@@ -526,8 +524,6 @@
                        (m_lastCurrentFrame, m_sourceSampleRate).toText().c_str()));
     }
     m_lastCurrentFrame = 0;
-
-    if (m_target) m_target->suspend();
 }
 
 void
--- a/framework/MainWindowBase.cpp	Wed Oct 14 15:08:55 2015 +0100
+++ b/framework/MainWindowBase.cpp	Wed Oct 14 16:02:09 2015 +0100
@@ -2203,6 +2203,7 @@
     } else {
         m_playTarget = breakfastquay::AudioFactory::
             createCallbackPlayTarget(m_playSource);
+        m_playTarget->suspend(); // start in suspended state
         m_playSource->setSystemPlaybackTarget(m_playTarget);
     }
 
@@ -2661,6 +2662,7 @@
         if (action) action->setChecked(false);
     } else {
         if (m_audioIO) m_audioIO->resume();
+        else if (m_playTarget) m_playTarget->resume();
         playbackFrameChanged(m_viewManager->getPlaybackFrame());
 	m_playSource->play(m_viewManager->getPlaybackFrame());
     }
@@ -2702,6 +2704,7 @@
     }
 
     m_audioIO->resume();
+
     WritableWaveFileModel *model = m_recordTarget->startRecording();
     if (!model) {
         cerr << "ERROR: MainWindowBase::record: Recording failed" << endl;
@@ -3039,6 +3042,7 @@
     m_playSource->stop();
 
     if (m_audioIO) m_audioIO->suspend();
+    else if (m_playTarget) m_playTarget->suspend();
     
     if (m_paneStack && m_paneStack->getCurrentPane()) {
         updateVisibleRangeDisplay(m_paneStack->getCurrentPane());