changeset 42:c0ae41c72421

* Bypass auditioning plugin on xrun
author Chris Cannam
date Wed, 04 Oct 2006 11:54:32 +0000
parents fbd7a497fd89
children 0739be123304
files audioio/AudioCallbackPlaySource.cpp audioio/AudioCallbackPlaySource.h audioio/AudioJACKTarget.cpp main/MainWindow.cpp main/MainWindow.h transform/TransformFactory.cpp
diffstat 6 files changed, 32 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/audioio/AudioCallbackPlaySource.cpp	Wed Oct 04 11:01:39 2006 +0000
+++ b/audioio/AudioCallbackPlaySource.cpp	Wed Oct 04 11:54:32 2006 +0000
@@ -54,6 +54,7 @@
     m_outputLeft(0.0),
     m_outputRight(0.0),
     m_auditioningPlugin(0),
+    m_auditioningPluginBypassed(false),
     m_timeStretcher(0),
     m_fillThread(0),
     m_converter(0),
@@ -401,6 +402,16 @@
 }
 
 void
+AudioCallbackPlaySource::audioProcessingOverload()
+{
+    RealTimePluginInstance *ap = m_auditioningPlugin;
+    if (ap && m_playing && !m_auditioningPluginBypassed) {
+        m_auditioningPluginBypassed = true;
+        emit audioOverloadPluginDisabled();
+    }
+}
+
+void
 AudioCallbackPlaySource::setTargetBlockSize(size_t size)
 {
 //    std::cerr << "AudioCallbackPlaySource::setTargetBlockSize() -> " << size << std::endl;
@@ -648,6 +659,7 @@
 {
     RealTimePluginInstance *formerPlugin = m_auditioningPlugin;
     m_auditioningPlugin = plugin;
+    m_auditioningPluginBypassed = false;
     if (formerPlugin) m_pluginScavenger.claim(formerPlugin);
 }
 
@@ -870,6 +882,7 @@
 void
 AudioCallbackPlaySource::applyAuditioningEffect(size_t count, float **buffers)
 {
+    if (m_auditioningPluginBypassed) return;
     RealTimePluginInstance *plugin = m_auditioningPlugin;
     if (!plugin) return;
 
--- a/audioio/AudioCallbackPlaySource.h	Wed Oct 04 11:01:39 2006 +0000
+++ b/audioio/AudioCallbackPlaySource.h	Wed Oct 04 11:54:32 2006 +0000
@@ -217,6 +217,11 @@
 
     void sampleRateMismatch(size_t requested, size_t available, bool willResample);
 
+    void audioOverloadPluginDisabled();
+
+public slots:
+    void audioProcessingOverload();
+
 protected slots:
     void selectionChanged();
     void playLoopModeChanged();
@@ -256,6 +261,7 @@
     float                             m_outputLeft;
     float                             m_outputRight;
     RealTimePluginInstance           *m_auditioningPlugin;
+    bool                              m_auditioningPluginBypassed;
     Scavenger<RealTimePluginInstance> m_pluginScavenger;
 
     RingBuffer<float> *getWriteRingBuffer(size_t c) {
--- a/audioio/AudioJACKTarget.cpp	Wed Oct 04 11:01:39 2006 +0000
+++ b/audioio/AudioJACKTarget.cpp	Wed Oct 04 11:54:32 2006 +0000
@@ -390,6 +390,7 @@
 AudioJACKTarget::xrun()
 {
     std::cerr << "AudioJACKTarget: xrun!" << std::endl;
+    if (m_source) m_source->audioProcessingOverload();
 }
 
 #ifdef INCLUDE_MOCFILES
--- a/main/MainWindow.cpp	Wed Oct 04 11:01:39 2006 +0000
+++ b/main/MainWindow.cpp	Wed Oct 04 11:54:32 2006 +0000
@@ -161,6 +161,8 @@
 
     connect(m_playSource, SIGNAL(sampleRateMismatch(size_t, size_t, bool)),
 	    this,           SLOT(sampleRateMismatch(size_t, size_t, bool)));
+    connect(m_playSource, SIGNAL(audioOverloadPluginDisabled()),
+            this,           SLOT(audioOverloadPluginDisabled()));
 
     m_fader = new Fader(frame, false);
 
@@ -3139,6 +3141,14 @@
 }
 
 void
+MainWindow::audioOverloadPluginDisabled()
+{
+    QMessageBox::information
+        (this, tr("Audio processing overload"),
+         tr("Audio effects plugin auditioning has been disabled\ndue to a processing overload."));
+}
+
+void
 MainWindow::layerAdded(Layer *layer)
 {
 //    std::cerr << "MainWindow::layerAdded(" << layer << ")" << std::endl;
--- a/main/MainWindow.h	Wed Oct 04 11:01:39 2006 +0000
+++ b/main/MainWindow.h	Wed Oct 04 11:54:32 2006 +0000
@@ -145,6 +145,7 @@
     void playSharpenToggled();
     void playMonoToggled();
     void sampleRateMismatch(size_t, size_t, bool);
+    void audioOverloadPluginDisabled();
 
     void outputLevelsChanged(float, float);
 
--- a/transform/TransformFactory.cpp	Wed Oct 04 11:01:39 2006 +0000
+++ b/transform/TransformFactory.cpp	Wed Oct 04 11:54:32 2006 +0000
@@ -534,6 +534,7 @@
         if (dialog->exec() == QDialog::Accepted) {
             ok = true;
         }
+
         configurationXml = PluginXml(plugin).toXmlString();
         context.channel = dialog->getChannel();