# HG changeset patch # User Chris Cannam # Date 1444814252 -3600 # Node ID dcd2afbc1bb707485ea1f3c0bfd453e2ca5d5a04 # Parent a4d90cf2bb79a896d7a967e8fec5ffeeae6266bc# Parent 40e7b4e1b5698c15f08e6269a9d35192cd0ef985 Merge, but dropping the last commit from the recording branch because I prefer the way it was done here diff -r 40e7b4e1b569 -r dcd2afbc1bb7 audio/AudioCallbackPlaySource.cpp --- a/audio/AudioCallbackPlaySource.cpp Mon Oct 12 15:06:02 2015 +0100 +++ b/audio/AudioCallbackPlaySource.cpp Wed Oct 14 10:17:32 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 diff -r 40e7b4e1b569 -r dcd2afbc1bb7 audio/AudioCallbackPlaySource.h --- a/audio/AudioCallbackPlaySource.h Mon Oct 12 15:06:02 2015 +0100 +++ b/audio/AudioCallbackPlaySource.h Wed Oct 14 10:17:32 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 *); diff -r 40e7b4e1b569 -r dcd2afbc1bb7 audio/AudioRecordTarget.cpp --- a/audio/AudioRecordTarget.cpp Mon Oct 12 15:06:02 2015 +0100 +++ b/audio/AudioRecordTarget.cpp Wed Oct 14 10:17:32 2015 +0100 @@ -19,11 +19,14 @@ #include "data/model/WritableWaveFileModel.h" +#include + #include AudioRecordTarget::AudioRecordTarget(ViewManagerBase *manager, QString clientName) : m_viewManager(manager), + m_source(0), m_clientName(clientName.toUtf8().data()), m_recording(false), m_recordSampleRate(44100), @@ -115,6 +118,7 @@ { { QMutexLocker locker(&m_mutex); + if (m_recording) { cerr << "WARNING: AudioRecordTarget::startRecording: We are already recording" << endl; return 0; diff -r 40e7b4e1b569 -r dcd2afbc1bb7 audio/AudioRecordTarget.h --- a/audio/AudioRecordTarget.h Mon Oct 12 15:06:02 2015 +0100 +++ b/audio/AudioRecordTarget.h Wed Oct 14 10:17:32 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; diff -r 40e7b4e1b569 -r dcd2afbc1bb7 framework/MainWindowBase.cpp --- a/framework/MainWindowBase.cpp Mon Oct 12 15:06:02 2015 +0100 +++ b/framework/MainWindowBase.cpp Wed Oct 14 10:17:32 2015 +0100 @@ -2200,6 +2200,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); @@ -2660,7 +2661,6 @@ QAction *action = qobject_cast(sender()); if (action) action->setChecked(false); } else { - if (m_audioIO) m_audioIO->resume(); playbackFrameChanged(m_viewManager->getPlaybackFrame()); m_playSource->play(m_viewManager->getPlaybackFrame()); } @@ -2702,7 +2702,6 @@ } m_audioIO->resume(); - WritableWaveFileModel *model = m_recordTarget->startRecording(); if (!model) { cerr << "ERROR: MainWindowBase::record: Recording failed" << endl; @@ -3038,8 +3037,6 @@ m_playSource->stop(); - if (m_audioIO) m_audioIO->suspend(); - if (m_paneStack && m_paneStack->getCurrentPane()) { updateVisibleRangeDisplay(m_paneStack->getCurrentPane()); } else {