Mercurial > hg > svapp
changeset 498:cd9dec2f47e8 recording
Fix suspending/resuming audio device; it wasn't suspending when playback reached the end, only when the user stopped explicitly
author | Chris Cannam |
---|---|
date | Tue, 22 Sep 2015 17:12:37 +0100 |
parents | 66b92c188cbd |
children | a4d90cf2bb79 |
files | audio/AudioCallbackPlaySource.cpp audio/AudioCallbackPlaySource.h audio/AudioRecordTarget.cpp audio/AudioRecordTarget.h framework/MainWindowBase.cpp |
diffstat | 5 files changed, 23 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/audio/AudioCallbackPlaySource.cpp Wed Sep 16 15:16:54 2015 +0100 +++ b/audio/AudioCallbackPlaySource.cpp Tue Sep 22 17:12:37 2015 +0100 @@ -407,6 +407,8 @@ 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; @@ -518,6 +520,8 @@ (m_lastCurrentFrame, m_sourceSampleRate).toText().c_str())); } m_lastCurrentFrame = 0; + + if (m_target) m_target->suspend(); } void
--- a/audio/AudioCallbackPlaySource.h Wed Sep 16 15:16:54 2015 +0100 +++ b/audio/AudioCallbackPlaySource.h Tue Sep 22 17:12:37 2015 +0100 @@ -116,8 +116,7 @@ virtual sv_frame_t getPlayEndFrame() { return m_lastModelEndFrame; } /** - * Set the playback target. This should be called by the target - * class. + * Set the playback target. */ virtual void setSystemPlaybackTarget(breakfastquay::SystemPlaybackTarget *);
--- a/audio/AudioRecordTarget.cpp Wed Sep 16 15:16:54 2015 +0100 +++ b/audio/AudioRecordTarget.cpp Tue Sep 22 17:12:37 2015 +0100 @@ -19,11 +19,14 @@ #include "data/model/WritableWaveFileModel.h" +#include <bqaudioio/SystemRecordSource.h> + #include <QDir> AudioRecordTarget::AudioRecordTarget(ViewManagerBase *manager, QString clientName) : m_viewManager(manager), + m_source(0), m_clientName(clientName.toUtf8().data()), m_recording(false), m_recordSampleRate(44100), @@ -38,6 +41,12 @@ } void +AudioRecordTarget::setSystemRecordSource(breakfastquay::SystemRecordSource *s) +{ + m_source = s; +} + +void AudioRecordTarget::setSystemRecordBlockSize(int sz) { } @@ -113,8 +122,11 @@ WritableWaveFileModel * AudioRecordTarget::startRecording() { + if (m_source) m_source->resume(); + { QMutexLocker locker(&m_mutex); + if (m_recording) { cerr << "WARNING: AudioRecordTarget::startRecording: We are already recording" << endl; return 0; @@ -169,6 +181,8 @@ m_recording = false; } + if (m_source) m_source->suspend(); + emit recordStatusChanged(false); }
--- a/audio/AudioRecordTarget.h Wed Sep 16 15:16:54 2015 +0100 +++ b/audio/AudioRecordTarget.h Tue Sep 22 17:12:37 2015 +0100 @@ -41,6 +41,8 @@ virtual int getApplicationSampleRate() const { return 0; } // don't care virtual int getApplicationChannelCount() const { return 2; } + virtual void setSystemRecordSource(breakfastquay::SystemRecordSource *); + virtual void setSystemRecordBlockSize(int); virtual void setSystemRecordSampleRate(int); virtual void setSystemRecordLatency(int); @@ -66,6 +68,7 @@ private: ViewManagerBase *m_viewManager; + breakfastquay::SystemRecordSource *m_source; std::string m_clientName; bool m_recording; sv_samplerate_t m_recordSampleRate;
--- a/framework/MainWindowBase.cpp Wed Sep 16 15:16:54 2015 +0100 +++ b/framework/MainWindowBase.cpp Tue Sep 22 17:12:37 2015 +0100 @@ -2202,6 +2202,7 @@ createCallbackIO(m_recordTarget, m_playSource); m_audioIO->suspend(); // start in suspended state m_playSource->setSystemPlaybackTarget(m_audioIO); + m_recordTarget->setSystemRecordSource(m_audioIO); } else { m_playTarget = breakfastquay::AudioFactory:: createCallbackPlayTarget(m_playSource); @@ -2662,7 +2663,6 @@ QAction *action = qobject_cast<QAction *>(sender()); if (action) action->setChecked(false); } else { - if (m_audioIO) m_audioIO->resume(); playbackFrameChanged(m_viewManager->getPlaybackFrame()); m_playSource->play(m_viewManager->getPlaybackFrame()); } @@ -2694,8 +2694,6 @@ if (!checkSaveModified()) return; } - if (m_audioIO) m_audioIO->resume(); - WritableWaveFileModel *model = m_recordTarget->startRecording(); if (!model) { cerr << "ERROR: MainWindowBase::record: Recording failed" << endl; @@ -3027,8 +3025,6 @@ m_playSource->stop(); - if (m_audioIO) m_audioIO->suspend(); - if (m_paneStack && m_paneStack->getCurrentPane()) { updateVisibleRangeDisplay(m_paneStack->getCurrentPane()); } else {