Mercurial > hg > svapp
comparison framework/MainWindowBase.cpp @ 570:6f54789f3127 3.0-integration
Fix race condition in first-time recording, where adding the recording wave model would prompt the audio play source to note that its channel count had increased (from 0 to, say, 2) and thus to cause the audio device to be reopened, stopping recording. Fix is to make this only happen if channel count increases beyond that of the device, which shouldn't happen in the recording case
author | Chris Cannam |
---|---|
date | Wed, 04 Jan 2017 11:48:03 +0000 |
parents | 1cc23cee4ebf |
children | 5369359351cb |
comparison
equal
deleted
inserted
replaced
569:1cc23cee4ebf | 570:6f54789f3127 |
---|---|
240 this, SLOT(recordDurationChanged(sv_frame_t, sv_samplerate_t))); | 240 this, SLOT(recordDurationChanged(sv_frame_t, sv_samplerate_t))); |
241 } | 241 } |
242 | 242 |
243 connect(m_playSource, SIGNAL(sampleRateMismatch(sv_samplerate_t, sv_samplerate_t, bool)), | 243 connect(m_playSource, SIGNAL(sampleRateMismatch(sv_samplerate_t, sv_samplerate_t, bool)), |
244 this, SLOT(sampleRateMismatch(sv_samplerate_t, sv_samplerate_t, bool))); | 244 this, SLOT(sampleRateMismatch(sv_samplerate_t, sv_samplerate_t, bool))); |
245 connect(m_playSource, SIGNAL(channelCountIncreased()), | 245 connect(m_playSource, SIGNAL(channelCountIncreased(int)), |
246 this, SLOT(recreateAudioIO())); | 246 this, SLOT(audioChannelCountIncreased(int))); |
247 connect(m_playSource, SIGNAL(audioOverloadPluginDisabled()), | 247 connect(m_playSource, SIGNAL(audioOverloadPluginDisabled()), |
248 this, SLOT(audioOverloadPluginDisabled())); | 248 this, SLOT(audioOverloadPluginDisabled())); |
249 connect(m_playSource, SIGNAL(audioTimeStretchMultiChannelDisabled()), | 249 connect(m_playSource, SIGNAL(audioTimeStretchMultiChannelDisabled()), |
250 this, SLOT(audioTimeStretchMultiChannelDisabled())); | 250 this, SLOT(audioTimeStretchMultiChannelDisabled())); |
251 | 251 |
2384 secondBit = tr("<p>Audio playback and recording will not be available during this session.</p>"); | 2384 secondBit = tr("<p>Audio playback and recording will not be available during this session.</p>"); |
2385 } else { | 2385 } else { |
2386 secondBit = tr("<p>Audio playback will not be available during this session.</p>"); | 2386 secondBit = tr("<p>Audio playback will not be available during this session.</p>"); |
2387 } | 2387 } |
2388 } | 2388 } |
2389 SVDEBUG << "createAudioIO: ERROR: Failed to open audio device \"" | |
2390 << implementation << "\": error is: " << error << endl; | |
2389 QMessageBox::warning(this, tr("Couldn't open audio device"), | 2391 QMessageBox::warning(this, tr("Couldn't open audio device"), |
2390 firstBit + secondBit, QMessageBox::Ok); | 2392 firstBit + secondBit, QMessageBox::Ok); |
2391 } | 2393 } |
2392 } | 2394 } |
2393 | 2395 |
2418 void | 2420 void |
2419 MainWindowBase::recreateAudioIO() | 2421 MainWindowBase::recreateAudioIO() |
2420 { | 2422 { |
2421 deleteAudioIO(); | 2423 deleteAudioIO(); |
2422 createAudioIO(); | 2424 createAudioIO(); |
2425 } | |
2426 | |
2427 void | |
2428 MainWindowBase::audioChannelCountIncreased(int) | |
2429 { | |
2430 recreateAudioIO(); | |
2423 } | 2431 } |
2424 | 2432 |
2425 WaveFileModel * | 2433 WaveFileModel * |
2426 MainWindowBase::getMainModel() | 2434 MainWindowBase::getMainModel() |
2427 { | 2435 { |
2876 //!!! report | 2884 //!!! report |
2877 return; | 2885 return; |
2878 } | 2886 } |
2879 | 2887 |
2880 if (!m_audioIO) { | 2888 if (!m_audioIO) { |
2889 cerr << "MainWindowBase::record: about to create audio IO" << endl; | |
2881 createAudioIO(); | 2890 createAudioIO(); |
2882 } | 2891 } |
2883 | 2892 |
2884 if (!m_audioIO) { | 2893 if (!m_audioIO) { |
2885 //!!! report | 2894 // don't need to report this, createAudioIO already should have |
2886 return; | 2895 return; |
2887 } | 2896 } |
2888 | 2897 |
2889 if (m_recordTarget->isRecording()) { | 2898 if (m_recordTarget->isRecording()) { |
2890 stop(); | 2899 stop(); |
2900 } | 2909 } |
2901 } | 2910 } |
2902 | 2911 |
2903 if (m_viewManager) m_viewManager->setGlobalCentreFrame(0); | 2912 if (m_viewManager) m_viewManager->setGlobalCentreFrame(0); |
2904 | 2913 |
2914 cerr << "MainWindowBase::record: about to resume" << endl; | |
2905 m_audioIO->resume(); | 2915 m_audioIO->resume(); |
2906 | 2916 |
2907 WritableWaveFileModel *model = m_recordTarget->startRecording(); | 2917 WritableWaveFileModel *model = m_recordTarget->startRecording(); |
2908 if (!model) { | 2918 if (!model) { |
2909 cerr << "ERROR: MainWindowBase::record: Recording failed" << endl; | 2919 cerr << "ERROR: MainWindowBase::record: Recording failed" << endl; |