Mercurial > hg > svapp
diff audio/AudioRecordTarget.cpp @ 485:21d3cf5c8f21 tony-2.0-integration
Add status bar "Recording" message and timer while recording
author | Chris Cannam |
---|---|
date | Wed, 16 Sep 2015 12:04:26 +0100 |
parents | 493f2af85497 |
children | 2f5ffd36879b cd9dec2f47e8 |
line wrap: on
line diff
--- a/audio/AudioRecordTarget.cpp Tue Sep 15 16:38:09 2015 +0100 +++ b/audio/AudioRecordTarget.cpp Wed Sep 16 12:04:26 2015 +0100 @@ -27,6 +27,7 @@ m_clientName(clientName.toUtf8().data()), m_recording(false), m_recordSampleRate(44100), + m_frameCount(0), m_model(0) { } @@ -55,9 +56,30 @@ void AudioRecordTarget::putSamples(int nframes, float **samples) { - QMutexLocker locker(&m_mutex); //!!! bad here - if (!m_recording) return; - m_model->addSamples(samples, nframes); + bool secChanged = false; + sv_frame_t frameToEmit = 0; + + { + QMutexLocker locker(&m_mutex); //!!! bad here + if (!m_recording) return; + + m_model->addSamples(samples, nframes); + + sv_frame_t priorFrameCount = m_frameCount; + m_frameCount += nframes; + + RealTime priorRT = RealTime::frame2RealTime + (priorFrameCount, m_recordSampleRate); + RealTime postRT = RealTime::frame2RealTime + (m_frameCount, m_recordSampleRate); + + secChanged = (postRT.sec > priorRT.sec); + if (secChanged) frameToEmit = m_frameCount; + } + + if (secChanged) { + emit recordDurationChanged(frameToEmit, m_recordSampleRate); + } } void @@ -99,6 +121,7 @@ } m_model = 0; + m_frameCount = 0; QString folder = getRecordFolder(); if (folder == "") return 0;