diff audio/AudioCallbackPlaySource.cpp @ 552:8c11ca1ebc39 bqresample

Some fixes to sample rate management
author Chris Cannam
date Fri, 09 Dec 2016 13:46:34 +0000
parents b9d8c7a690d6
children 2a1e9e017484
line wrap: on
line diff
--- a/audio/AudioCallbackPlaySource.cpp	Wed Dec 07 13:57:45 2016 +0000
+++ b/audio/AudioCallbackPlaySource.cpp	Fri Dec 09 13:46:34 2016 +0000
@@ -230,13 +230,15 @@
 	if (willPlay) clearRingBuffers(true);
     }
 
-    if (buffersChanged || srChanged) {
-
-        // There are more channels than there were before, or the
-        // source sample rate has changed
-
-        //!!!
-
+    if (srChanged) {
+        SVCERR << "AudioCallbackPlaySource: Source rate changed" << endl;
+        if (m_resamplerWrapper) {
+            SVCERR << "AudioCallbackPlaySource: Source sample rate changed to "
+                << m_sourceSampleRate << ", updating resampler wrapper" << endl;
+            m_resamplerWrapper->changeApplicationSampleRate
+                (int(round(m_sourceSampleRate)));
+            m_resamplerWrapper->reset();
+        }
     }
 
     rebuildRangeLists();
@@ -540,7 +542,7 @@
 }
 
 void
-AudioCallbackPlaySource::preferenceChanged(PropertyContainer::PropertyName n)
+AudioCallbackPlaySource::preferenceChanged(PropertyContainer::PropertyName )
 {
 }
 
@@ -578,6 +580,10 @@
 AudioCallbackPlaySource::setResamplerWrapper(breakfastquay::ResamplerWrapper *w)
 {
     m_resamplerWrapper = w;
+    if (m_resamplerWrapper && m_sourceSampleRate != 0) {
+        m_resamplerWrapper->changeApplicationSampleRate
+            (int(round(m_sourceSampleRate)));
+    }
 }
 
 void
@@ -944,7 +950,7 @@
 }
 
 void
-AudioCallbackPlaySource::setSystemPlaybackChannelCount(int c)
+AudioCallbackPlaySource::setSystemPlaybackChannelCount(int)
 {
 }
 
@@ -1336,8 +1342,6 @@
 
     int channels = getTargetChannelCount();
 
-    sv_frame_t orig = space;
-
     static float **bufferPtrs = 0;
     static int bufferPtrCount = 0;