diff 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
line wrap: on
line diff
--- a/framework/MainWindowBase.cpp	Wed Jan 04 09:57:13 2017 +0000
+++ b/framework/MainWindowBase.cpp	Wed Jan 04 11:48:03 2017 +0000
@@ -242,8 +242,8 @@
 
     connect(m_playSource, SIGNAL(sampleRateMismatch(sv_samplerate_t, sv_samplerate_t, bool)),
 	    this,           SLOT(sampleRateMismatch(sv_samplerate_t, sv_samplerate_t, bool)));
-    connect(m_playSource, SIGNAL(channelCountIncreased()),
-            this,           SLOT(recreateAudioIO()));
+    connect(m_playSource, SIGNAL(channelCountIncreased(int)),
+            this,           SLOT(audioChannelCountIncreased(int)));
     connect(m_playSource, SIGNAL(audioOverloadPluginDisabled()),
             this,           SLOT(audioOverloadPluginDisabled()));
     connect(m_playSource, SIGNAL(audioTimeStretchMultiChannelDisabled()),
@@ -2386,6 +2386,8 @@
                 secondBit = tr("<p>Audio playback will not be available during this session.</p>");
             }
         }
+        SVDEBUG << "createAudioIO: ERROR: Failed to open audio device \""
+                << implementation << "\": error is: " << error << endl;
         QMessageBox::warning(this, tr("Couldn't open audio device"),
                              firstBit + secondBit, QMessageBox::Ok);
     }
@@ -2422,6 +2424,12 @@
     createAudioIO();
 }
 
+void
+MainWindowBase::audioChannelCountIncreased(int)
+{
+    recreateAudioIO();
+}
+
 WaveFileModel *
 MainWindowBase::getMainModel()
 {
@@ -2878,11 +2886,12 @@
     }
 
     if (!m_audioIO) {
+        cerr << "MainWindowBase::record: about to create audio IO" << endl;
         createAudioIO();
     }
 
     if (!m_audioIO) {
-        //!!! report
+        // don't need to report this, createAudioIO already should have
         return;
     }
     
@@ -2902,6 +2911,7 @@
 
     if (m_viewManager) m_viewManager->setGlobalCentreFrame(0);
     
+    cerr << "MainWindowBase::record: about to resume" << endl;
     m_audioIO->resume();
 
     WritableWaveFileModel *model = m_recordTarget->startRecording();