comparison framework/MainWindowBase.cpp @ 611:37b23e50832b

Smoother model updates, some debug
author Chris Cannam
date Wed, 08 Aug 2018 15:19:06 +0100
parents 5ddcbc55b6a2
children 636a5908cf81
comparison
equal deleted inserted replaced
610:5ddcbc55b6a2 611:37b23e50832b
2457 if (m_soundOptions & WithAudioInput) { 2457 if (m_soundOptions & WithAudioInput) {
2458 m_audioIO = breakfastquay::AudioFactory:: 2458 m_audioIO = breakfastquay::AudioFactory::
2459 createCallbackIO(m_recordTarget, m_resamplerWrapper, 2459 createCallbackIO(m_recordTarget, m_resamplerWrapper,
2460 preference, errorString); 2460 preference, errorString);
2461 if (m_audioIO) { 2461 if (m_audioIO) {
2462 SVCERR << "MainWindowBase::createAudioIO: Suspending on creation" << endl;
2462 m_audioIO->suspend(); // start in suspended state 2463 m_audioIO->suspend(); // start in suspended state
2463 m_playSource->setSystemPlaybackTarget(m_audioIO); 2464 m_playSource->setSystemPlaybackTarget(m_audioIO);
2464 } else { 2465 } else {
2465 // Failed to create audio I/O; this may just mean there is 2466 // Failed to create audio I/O; this may just mean there is
2466 // no record device, so fall through to see what happens 2467 // no record device, so fall through to see what happens
2472 if (!m_audioIO) { 2473 if (!m_audioIO) {
2473 m_playTarget = breakfastquay::AudioFactory:: 2474 m_playTarget = breakfastquay::AudioFactory::
2474 createCallbackPlayTarget(m_resamplerWrapper, 2475 createCallbackPlayTarget(m_resamplerWrapper,
2475 preference, errorString); 2476 preference, errorString);
2476 if (m_playTarget) { 2477 if (m_playTarget) {
2478 SVCERR << "MainWindowBase::createAudioIO: Suspending on creation" << endl;
2477 m_playTarget->suspend(); // start in suspended state 2479 m_playTarget->suspend(); // start in suspended state
2478 m_playSource->setSystemPlaybackTarget(m_playTarget); 2480 m_playSource->setSystemPlaybackTarget(m_playTarget);
2479 } 2481 }
2480 } 2482 }
2481 2483
2549 } 2551 }
2550 2552
2551 void 2553 void
2552 MainWindowBase::audioChannelCountIncreased(int) 2554 MainWindowBase::audioChannelCountIncreased(int)
2553 { 2555 {
2556 SVCERR << "MainWindowBase::audioChannelCountIncreased" << endl;
2554 recreateAudioIO(); 2557 recreateAudioIO();
2555 2558
2556 if (m_recordTarget && 2559 if (m_recordTarget &&
2557 m_recordTarget->isRecording() && 2560 m_recordTarget->isRecording() &&
2558 m_audioIO) { 2561 m_audioIO) {
3034 if (action) action->setChecked(false); 3037 if (action) action->setChecked(false);
3035 return; 3038 return;
3036 } 3039 }
3037 3040
3038 if (!m_audioIO) { 3041 if (!m_audioIO) {
3039 cerr << "MainWindowBase::record: about to create audio IO" << endl; 3042 SVDEBUG << "MainWindowBase::record: about to create audio IO" << endl;
3040 createAudioIO(); 3043 createAudioIO();
3041 } 3044 }
3042 3045
3043 if (!m_audioIO) { 3046 if (!m_audioIO) {
3044 if (!m_playTarget) { 3047 if (!m_playTarget) {
3073 } 3076 }
3074 } 3077 }
3075 3078
3076 if (m_viewManager) m_viewManager->setGlobalCentreFrame(0); 3079 if (m_viewManager) m_viewManager->setGlobalCentreFrame(0);
3077 3080
3078 SVDEBUG << "MainWindowBase::record: about to resume" << endl; 3081 SVCERR << "MainWindowBase::record: about to resume" << endl;
3079 m_audioIO->resume(); 3082 m_audioIO->resume();
3080 3083
3081 WritableWaveFileModel *model = m_recordTarget->startRecording(); 3084 WritableWaveFileModel *model = m_recordTarget->startRecording();
3082 if (!model) { 3085 if (!model) {
3083 SVCERR << "ERROR: MainWindowBase::record: Recording failed" << endl; 3086 SVCERR << "ERROR: MainWindowBase::record: Recording failed" << endl;
3087 if (action) action->setChecked(false); 3090 if (action) action->setChecked(false);
3088 return; 3091 return;
3089 } 3092 }
3090 3093
3091 if (!model->isOK()) { 3094 if (!model->isOK()) {
3095 SVCERR << "MainWindowBase::record: Model not OK, stopping and suspending" << endl;
3092 m_recordTarget->stopRecording(); 3096 m_recordTarget->stopRecording();
3093 m_audioIO->suspend(); 3097 m_audioIO->suspend();
3094 if (action) action->setChecked(false); 3098 if (action) action->setChecked(false);
3095 delete model; 3099 delete model;
3096 return; 3100 return;
3097 } 3101 }
3102
3103 SVCERR << "MainWindowBase::record: Model is OK, continuing..." << endl;
3098 3104
3099 PlayParameterRepository::getInstance()->addPlayable(model); 3105 PlayParameterRepository::getInstance()->addPlayable(model);
3100 3106
3101 if (m_audioRecordMode == RecordReplaceSession || !getMainModel()) { 3107 if (m_audioRecordMode == RecordReplaceSession || !getMainModel()) {
3102 3108
3106 bool loadedTemplate = false; 3112 bool loadedTemplate = false;
3107 3113
3108 if (templateName != "") { 3114 if (templateName != "") {
3109 FileOpenStatus tplStatus = openSessionTemplate(templateName); 3115 FileOpenStatus tplStatus = openSessionTemplate(templateName);
3110 if (tplStatus == FileOpenCancelled) { 3116 if (tplStatus == FileOpenCancelled) {
3117 SVCERR << "MainWindowBase::record: Session template open cancelled, stopping and suspending" << endl;
3111 m_recordTarget->stopRecording(); 3118 m_recordTarget->stopRecording();
3112 m_audioIO->suspend(); 3119 m_audioIO->suspend();
3113 PlayParameterRepository::getInstance()->removePlayable(model); 3120 PlayParameterRepository::getInstance()->removePlayable(model);
3114 return; 3121 return;
3115 } 3122 }
3178 } 3185 }
3179 3186
3180 updateMenuStates(); 3187 updateMenuStates();
3181 m_recentFiles.addFile(model->getLocation()); 3188 m_recentFiles.addFile(model->getLocation());
3182 currentPaneChanged(m_paneStack->getCurrentPane()); 3189 currentPaneChanged(m_paneStack->getCurrentPane());
3183 3190
3184 emit audioFileLoaded(); 3191 emit audioFileLoaded();
3185 } 3192 }
3186 3193
3187 void 3194 void
3188 MainWindowBase::ffwd() 3195 MainWindowBase::ffwd()
3419 3426
3420 if (!m_playSource) return; 3427 if (!m_playSource) return;
3421 3428
3422 m_playSource->stop(); 3429 m_playSource->stop();
3423 3430
3431 SVCERR << "MainWindowBase::stop: suspending" << endl;
3432
3424 if (m_audioIO) m_audioIO->suspend(); 3433 if (m_audioIO) m_audioIO->suspend();
3425 else if (m_playTarget) m_playTarget->suspend(); 3434 else if (m_playTarget) m_playTarget->suspend();
3426 3435
3427 if (m_paneStack && m_paneStack->getCurrentPane()) { 3436 if (m_paneStack && m_paneStack->getCurrentPane()) {
3428 updateVisibleRangeDisplay(m_paneStack->getCurrentPane()); 3437 updateVisibleRangeDisplay(m_paneStack->getCurrentPane());