Mercurial > hg > svapp
changeset 33:3e0794460c4e
* Ensure consistent ordering of layer text labels
* Fix erroneous SR mismatch warning when adding a wave-file model when
no other wave-file model is present (only models that don't assert any
particular playback samplerate)
author | Chris Cannam |
---|---|
date | Thu, 27 Apr 2006 11:49:34 +0000 |
parents | 42989c2e621b |
children | f6b15e0b6fde |
files | audioio/AudioCallbackPlaySource.cpp |
diffstat | 1 files changed, 41 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/audioio/AudioCallbackPlaySource.cpp Wed Apr 26 16:00:13 2006 +0000 +++ b/audioio/AudioCallbackPlaySource.cpp Thu Apr 27 11:49:34 2006 +0000 @@ -107,24 +107,6 @@ bool buffersChanged = false, srChanged = false; - if (m_sourceSampleRate == 0) { - - m_sourceSampleRate = model->getSampleRate(); - srChanged = true; - - } else if (model->getSampleRate() != m_sourceSampleRate) { - std::cerr << "AudioCallbackPlaySource::addModel: ERROR: " - << "New model sample rate does not match" << std::endl - << "existing model(s) (new " << model->getSampleRate() - << " vs " << m_sourceSampleRate - << "), playback will be wrong" - << std::endl; - if (dynamic_cast<DenseTimeValueModel *>(model)) { - emit sampleRateMismatch(model->getSampleRate(), m_sourceSampleRate, - false); - } - } - size_t modelChannels = 1; DenseTimeValueModel *dtvm = dynamic_cast<DenseTimeValueModel *>(model); if (dtvm) modelChannels = dtvm->getChannelCount(); @@ -134,6 +116,47 @@ std::cerr << "Adding model with " << modelChannels << " channels " << std::endl; + if (m_sourceSampleRate == 0) { + + m_sourceSampleRate = model->getSampleRate(); + srChanged = true; + + } else if (model->getSampleRate() != m_sourceSampleRate) { + + // If this is a dense time-value model and we have no other, we + // can just switch to this model's sample rate + + if (dtvm) { + + bool conflicting = false; + + for (std::set<Model *>::const_iterator i = m_models.begin(); + i != m_models.end(); ++i) { + if (*i != dtvm && dynamic_cast<DenseTimeValueModel *>(*i)) { + std::cerr << "AudioCallbackPlaySource::addModel: Conflicting dense time-value model " << *i << " found" << std::endl; + conflicting = true; + break; + } + } + + if (conflicting) { + + std::cerr << "AudioCallbackPlaySource::addModel: ERROR: " + << "New model sample rate does not match" << std::endl + << "existing model(s) (new " << model->getSampleRate() + << " vs " << m_sourceSampleRate + << "), playback will be wrong" + << std::endl; + + emit sampleRateMismatch(model->getSampleRate(), m_sourceSampleRate, + false); + } else { + m_sourceSampleRate = model->getSampleRate(); + srChanged = true; + } + } + } + if (!m_writeBuffers || (m_writeBuffers->size() < getTargetChannelCount())) { clearRingBuffers(true, getTargetChannelCount()); buffersChanged = true;