comparison audioio/AudioCallbackPlaySource.cpp @ 244:f853dfb200de

Avoid creating a time stretcher if no sample rate set (SF bug #3376634)
author Chris Cannam
date Wed, 28 Sep 2011 13:24:49 +0100
parents 8aace2d9f1c2
children 0136555495ae cba1e2a3d14b 068235cf5bf7
comparison
equal deleted inserted replaced
243:6a730f6bd010 244:f853dfb200de
894 } 894 }
895 895
896 void 896 void
897 AudioCallbackPlaySource::setTargetSampleRate(size_t sr) 897 AudioCallbackPlaySource::setTargetSampleRate(size_t sr)
898 { 898 {
899 bool first = (m_targetSampleRate == 0);
900
899 m_targetSampleRate = sr; 901 m_targetSampleRate = sr;
900 initialiseConverter(); 902 initialiseConverter();
903
904 if (first && (m_stretchRatio != 1.f)) {
905 // couldn't create a stretcher before because we had no sample
906 // rate: make one now
907 setTimeStretch(m_stretchRatio);
908 }
901 } 909 }
902 910
903 void 911 void
904 AudioCallbackPlaySource::initialiseConverter() 912 AudioCallbackPlaySource::initialiseConverter()
905 { 913 {
1031 1039
1032 void 1040 void
1033 AudioCallbackPlaySource::setTimeStretch(float factor) 1041 AudioCallbackPlaySource::setTimeStretch(float factor)
1034 { 1042 {
1035 m_stretchRatio = factor; 1043 m_stretchRatio = factor;
1044
1045 if (!getTargetSampleRate()) return; // have to make our stretcher later
1036 1046
1037 if (m_timeStretcher || (factor == 1.f)) { 1047 if (m_timeStretcher || (factor == 1.f)) {
1038 // stretch ratio will be set in next process call if appropriate 1048 // stretch ratio will be set in next process call if appropriate
1039 } else { 1049 } else {
1040 m_stretcherInputCount = getTargetChannelCount(); 1050 m_stretcherInputCount = getTargetChannelCount();