diff audio/AudioCallbackPlaySource.cpp @ 566:36076ef960fb levelpanwidget

A useful simplification in rate handling: don't reset to 0 when last model goes
author Chris Cannam
date Sat, 17 Dec 2016 11:06:48 +0000
parents ce3818cd16c5
children 6f54789f3127
line wrap: on
line diff
--- a/audio/AudioCallbackPlaySource.cpp	Thu Dec 15 10:36:41 2016 +0000
+++ b/audio/AudioCallbackPlaySource.cpp	Sat Dec 17 11:06:48 2016 +0000
@@ -178,6 +178,9 @@
 
     if (m_sourceSampleRate == 0) {
 
+        SVDEBUG << "AudioCallbackPlaySource::addModel: Source rate changing from 0 to "
+            << model->getSampleRate() << endl;
+
 	m_sourceSampleRate = model->getSampleRate();
 	srChanged = true;
 
@@ -222,6 +225,9 @@
                                         m_sourceSampleRate,
                                         false);
             } else {
+                SVDEBUG << "AudioCallbackPlaySource::addModel: Source rate changing from "
+                        << m_sourceSampleRate << " to " << model->getSampleRate() << endl;
+                
                 m_sourceSampleRate = model->getSampleRate();
                 srChanged = true;
             }
@@ -317,9 +323,15 @@
 
     m_models.erase(model);
 
-    if (m_models.empty()) {
-	m_sourceSampleRate = 0;
-    }
+    // I don't think we have to do this any more: if a new model is
+    // loaded at a different rate, we'll hit the non-conflicting path
+    // in addModel and the rate will be updated without problems; but
+    // if a new model is loaded at the rate that we were using for the
+    // last one, then we save work by not having reset this here
+    //
+//    if (m_models.empty()) {
+//	m_sourceSampleRate = 0;
+//    }
 
     sv_frame_t lastEnd = 0;
     for (std::set<Model *>::const_iterator i = m_models.begin();