Mercurial > hg > svapp
changeset 611:37b23e50832b
Smoother model updates, some debug
author | Chris Cannam |
---|---|
date | Wed, 08 Aug 2018 15:19:06 +0100 |
parents | 5ddcbc55b6a2 |
children | 1822563a5da1 |
files | audio/AudioCallbackRecordTarget.cpp framework/MainWindowBase.cpp |
diffstat | 2 files changed, 25 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
--- a/audio/AudioCallbackRecordTarget.cpp Wed Aug 08 15:18:52 2018 +0100 +++ b/audio/AudioCallbackRecordTarget.cpp Wed Aug 08 15:19:06 2018 +0100 @@ -142,6 +142,10 @@ void AudioCallbackRecordTarget::updateModel() { +#ifdef DEBUG_AUDIO_CALLBACK_RECORD_TARGET + cerr << "AudioCallbackRecordTarget::updateModel" << endl; +#endif + bool secChanged = false; sv_frame_t frameToEmit = 0; @@ -162,6 +166,10 @@ return; } +#ifdef DEBUG_AUDIO_CALLBACK_RECORD_TARGET + cerr << "AudioCallbackRecordTarget::updateModel: have " << nframes << " frames" << endl; +#endif + float **samples = new float *[m_recordChannelCount]; for (int c = 0; c < m_recordChannelCount; ++c) { samples[c] = new float[nframes]; @@ -177,25 +185,13 @@ 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) { - m_model->updateModel(); - frameToEmit = m_frameCount; - } - - if (secChanged) { - emit recordDurationChanged(frameToEmit, m_recordSampleRate); - } + m_model->updateModel(); + frameToEmit = m_frameCount; + emit recordDurationChanged(frameToEmit, m_recordSampleRate); if (m_recording) { - QTimer::singleShot(1000, this, SLOT(updateModel())); + QTimer::singleShot(recordUpdateTimeout, this, SLOT(updateModel())); } } @@ -301,7 +297,7 @@ emit recordStatusChanged(true); - QTimer::singleShot(1000, this, SLOT(updateModel())); + QTimer::singleShot(recordUpdateTimeout, this, SLOT(updateModel())); return m_model; }
--- a/framework/MainWindowBase.cpp Wed Aug 08 15:18:52 2018 +0100 +++ b/framework/MainWindowBase.cpp Wed Aug 08 15:19:06 2018 +0100 @@ -2459,6 +2459,7 @@ createCallbackIO(m_recordTarget, m_resamplerWrapper, preference, errorString); if (m_audioIO) { + SVCERR << "MainWindowBase::createAudioIO: Suspending on creation" << endl; m_audioIO->suspend(); // start in suspended state m_playSource->setSystemPlaybackTarget(m_audioIO); } else { @@ -2474,6 +2475,7 @@ createCallbackPlayTarget(m_resamplerWrapper, preference, errorString); if (m_playTarget) { + SVCERR << "MainWindowBase::createAudioIO: Suspending on creation" << endl; m_playTarget->suspend(); // start in suspended state m_playSource->setSystemPlaybackTarget(m_playTarget); } @@ -2551,6 +2553,7 @@ void MainWindowBase::audioChannelCountIncreased(int) { + SVCERR << "MainWindowBase::audioChannelCountIncreased" << endl; recreateAudioIO(); if (m_recordTarget && @@ -3036,7 +3039,7 @@ } if (!m_audioIO) { - cerr << "MainWindowBase::record: about to create audio IO" << endl; + SVDEBUG << "MainWindowBase::record: about to create audio IO" << endl; createAudioIO(); } @@ -3075,7 +3078,7 @@ if (m_viewManager) m_viewManager->setGlobalCentreFrame(0); - SVDEBUG << "MainWindowBase::record: about to resume" << endl; + SVCERR << "MainWindowBase::record: about to resume" << endl; m_audioIO->resume(); WritableWaveFileModel *model = m_recordTarget->startRecording(); @@ -3089,12 +3092,15 @@ } if (!model->isOK()) { + SVCERR << "MainWindowBase::record: Model not OK, stopping and suspending" << endl; m_recordTarget->stopRecording(); m_audioIO->suspend(); if (action) action->setChecked(false); delete model; return; } + + SVCERR << "MainWindowBase::record: Model is OK, continuing..." << endl; PlayParameterRepository::getInstance()->addPlayable(model); @@ -3108,6 +3114,7 @@ if (templateName != "") { FileOpenStatus tplStatus = openSessionTemplate(templateName); if (tplStatus == FileOpenCancelled) { + SVCERR << "MainWindowBase::record: Session template open cancelled, stopping and suspending" << endl; m_recordTarget->stopRecording(); m_audioIO->suspend(); PlayParameterRepository::getInstance()->removePlayable(model); @@ -3180,7 +3187,7 @@ updateMenuStates(); m_recentFiles.addFile(model->getLocation()); currentPaneChanged(m_paneStack->getCurrentPane()); - + emit audioFileLoaded(); } @@ -3421,6 +3428,8 @@ m_playSource->stop(); + SVCERR << "MainWindowBase::stop: suspending" << endl; + if (m_audioIO) m_audioIO->suspend(); else if (m_playTarget) m_playTarget->suspend();