diff framework/MainWindowBase.cpp @ 618:636a5908cf81 import-audio-data

Merge from default branch
author Chris Cannam
date Tue, 04 Sep 2018 13:19:43 +0100
parents 6cdf2afebfd7 37b23e50832b
children 0e95c30d6680
line wrap: on
line diff
--- a/framework/MainWindowBase.cpp	Thu Jun 28 15:29:26 2018 +0100
+++ b/framework/MainWindowBase.cpp	Tue Sep 04 13:19:43 2018 +0100
@@ -2469,6 +2469,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 {
@@ -2484,6 +2485,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);
         }
@@ -2561,7 +2563,15 @@
 void
 MainWindowBase::audioChannelCountIncreased(int)
 {
+    SVCERR << "MainWindowBase::audioChannelCountIncreased" << endl;
     recreateAudioIO();
+
+    if (m_recordTarget &&
+        m_recordTarget->isRecording() &&
+        m_audioIO) {
+        SVCERR << "MainWindowBase::audioChannelCountIncreased: we were recording already, so resuming IO now" << endl;
+        m_audioIO->resume();
+    }
 }
 
 WaveFileModel *
@@ -3039,7 +3049,7 @@
     }
 
     if (!m_audioIO) {
-        cerr << "MainWindowBase::record: about to create audio IO" << endl;
+        SVDEBUG << "MainWindowBase::record: about to create audio IO" << endl;
         createAudioIO();
     }
 
@@ -3078,7 +3088,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();
@@ -3092,12 +3102,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);
 
@@ -3111,6 +3124,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);
@@ -3183,7 +3197,7 @@
     updateMenuStates();
     m_recentFiles.addFile(model->getLocation());
     currentPaneChanged(m_paneStack->getCurrentPane());
-
+    
     emit audioFileLoaded();
 }
 
@@ -3424,6 +3438,8 @@
     
     m_playSource->stop();
 
+    SVCERR << "MainWindowBase::stop: suspending" << endl;
+    
     if (m_audioIO) m_audioIO->suspend();
     else if (m_playTarget) m_playTarget->suspend();
     
@@ -4062,13 +4078,18 @@
         QProcess::execute("c:/windows/explorer.exe", args);
 #else
         args << path;
-        QProcess::execute(
+        QProcess process;
+        QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
+        env.insert("LD_LIBRARY_PATH", "");
+        process.setProcessEnvironment(env);
+        process.start(
 #if defined Q_OS_MAC
             "/usr/bin/open",
 #else
             "/usr/bin/xdg-open",
 #endif
             args);
+        process.waitForFinished();
 #endif
     }
 }