Mercurial > hg > svapp
changeset 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 | 6a730f6bd010 | 
| children | eaef94d9f9bf | 
| files | audioio/AudioCallbackPlaySource.cpp | 
| diffstat | 1 files changed, 10 insertions(+), 0 deletions(-) [+] | 
line wrap: on
 line diff
--- a/audioio/AudioCallbackPlaySource.cpp Wed Sep 28 10:17:35 2011 +0100 +++ b/audioio/AudioCallbackPlaySource.cpp Wed Sep 28 13:24:49 2011 +0100 @@ -896,8 +896,16 @@ void AudioCallbackPlaySource::setTargetSampleRate(size_t sr) { + bool first = (m_targetSampleRate == 0); + m_targetSampleRate = sr; initialiseConverter(); + + if (first && (m_stretchRatio != 1.f)) { + // couldn't create a stretcher before because we had no sample + // rate: make one now + setTimeStretch(m_stretchRatio); + } } void @@ -1034,6 +1042,8 @@ { m_stretchRatio = factor; + if (!getTargetSampleRate()) return; // have to make our stretcher later + if (m_timeStretcher || (factor == 1.f)) { // stretch ratio will be set in next process call if appropriate } else {
