comparison 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
comparison
equal deleted inserted replaced
551:b9d8c7a690d6 552:8c11ca1ebc39
228 buffersChanged = true; 228 buffersChanged = true;
229 } else { 229 } else {
230 if (willPlay) clearRingBuffers(true); 230 if (willPlay) clearRingBuffers(true);
231 } 231 }
232 232
233 if (buffersChanged || srChanged) { 233 if (srChanged) {
234 234 SVCERR << "AudioCallbackPlaySource: Source rate changed" << endl;
235 // There are more channels than there were before, or the 235 if (m_resamplerWrapper) {
236 // source sample rate has changed 236 SVCERR << "AudioCallbackPlaySource: Source sample rate changed to "
237 237 << m_sourceSampleRate << ", updating resampler wrapper" << endl;
238 //!!! 238 m_resamplerWrapper->changeApplicationSampleRate
239 239 (int(round(m_sourceSampleRate)));
240 m_resamplerWrapper->reset();
241 }
240 } 242 }
241 243
242 rebuildRangeLists(); 244 rebuildRangeLists();
243 245
244 m_mutex.unlock(); 246 m_mutex.unlock();
538 { 540 {
539 clearRingBuffers(); 541 clearRingBuffers();
540 } 542 }
541 543
542 void 544 void
543 AudioCallbackPlaySource::preferenceChanged(PropertyContainer::PropertyName n) 545 AudioCallbackPlaySource::preferenceChanged(PropertyContainer::PropertyName )
544 { 546 {
545 } 547 }
546 548
547 void 549 void
548 AudioCallbackPlaySource::audioProcessingOverload() 550 AudioCallbackPlaySource::audioProcessingOverload()
576 578
577 void 579 void
578 AudioCallbackPlaySource::setResamplerWrapper(breakfastquay::ResamplerWrapper *w) 580 AudioCallbackPlaySource::setResamplerWrapper(breakfastquay::ResamplerWrapper *w)
579 { 581 {
580 m_resamplerWrapper = w; 582 m_resamplerWrapper = w;
583 if (m_resamplerWrapper && m_sourceSampleRate != 0) {
584 m_resamplerWrapper->changeApplicationSampleRate
585 (int(round(m_sourceSampleRate)));
586 }
581 } 587 }
582 588
583 void 589 void
584 AudioCallbackPlaySource::setSystemPlaybackBlockSize(int size) 590 AudioCallbackPlaySource::setSystemPlaybackBlockSize(int size)
585 { 591 {
942 setTimeStretch(m_stretchRatio); 948 setTimeStretch(m_stretchRatio);
943 } 949 }
944 } 950 }
945 951
946 void 952 void
947 AudioCallbackPlaySource::setSystemPlaybackChannelCount(int c) 953 AudioCallbackPlaySource::setSystemPlaybackChannelCount(int)
948 { 954 {
949 } 955 }
950 956
951 void 957 void
952 AudioCallbackPlaySource::setAuditioningEffect(Auditionable *a) 958 AudioCallbackPlaySource::setAuditioningEffect(Auditionable *a)
1334 cout << "buffered to " << f << " already" << endl; 1340 cout << "buffered to " << f << " already" << endl;
1335 #endif 1341 #endif
1336 1342
1337 int channels = getTargetChannelCount(); 1343 int channels = getTargetChannelCount();
1338 1344
1339 sv_frame_t orig = space;
1340
1341 static float **bufferPtrs = 0; 1345 static float **bufferPtrs = 0;
1342 static int bufferPtrCount = 0; 1346 static int bufferPtrCount = 0;
1343 1347
1344 if (bufferPtrCount < channels) { 1348 if (bufferPtrCount < channels) {
1345 if (bufferPtrs) delete[] bufferPtrs; 1349 if (bufferPtrs) delete[] bufferPtrs;