Mercurial > hg > svapp
diff 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 |
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 {