comparison audioio/AudioCallbackPlaySource.cpp @ 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 f38b8abd3540
children f6b15e0b6fde
comparison
equal deleted inserted replaced
32:42989c2e621b 33:3e0794460c4e
105 m_lastModelEndFrame = model->getEndFrame(); 105 m_lastModelEndFrame = model->getEndFrame();
106 } 106 }
107 107
108 bool buffersChanged = false, srChanged = false; 108 bool buffersChanged = false, srChanged = false;
109 109
110 if (m_sourceSampleRate == 0) {
111
112 m_sourceSampleRate = model->getSampleRate();
113 srChanged = true;
114
115 } else if (model->getSampleRate() != m_sourceSampleRate) {
116 std::cerr << "AudioCallbackPlaySource::addModel: ERROR: "
117 << "New model sample rate does not match" << std::endl
118 << "existing model(s) (new " << model->getSampleRate()
119 << " vs " << m_sourceSampleRate
120 << "), playback will be wrong"
121 << std::endl;
122 if (dynamic_cast<DenseTimeValueModel *>(model)) {
123 emit sampleRateMismatch(model->getSampleRate(), m_sourceSampleRate,
124 false);
125 }
126 }
127
128 size_t modelChannels = 1; 110 size_t modelChannels = 1;
129 DenseTimeValueModel *dtvm = dynamic_cast<DenseTimeValueModel *>(model); 111 DenseTimeValueModel *dtvm = dynamic_cast<DenseTimeValueModel *>(model);
130 if (dtvm) modelChannels = dtvm->getChannelCount(); 112 if (dtvm) modelChannels = dtvm->getChannelCount();
131 if (modelChannels > m_sourceChannelCount) { 113 if (modelChannels > m_sourceChannelCount) {
132 m_sourceChannelCount = modelChannels; 114 m_sourceChannelCount = modelChannels;
133 } 115 }
134 116
135 std::cerr << "Adding model with " << modelChannels << " channels " << std::endl; 117 std::cerr << "Adding model with " << modelChannels << " channels " << std::endl;
118
119 if (m_sourceSampleRate == 0) {
120
121 m_sourceSampleRate = model->getSampleRate();
122 srChanged = true;
123
124 } else if (model->getSampleRate() != m_sourceSampleRate) {
125
126 // If this is a dense time-value model and we have no other, we
127 // can just switch to this model's sample rate
128
129 if (dtvm) {
130
131 bool conflicting = false;
132
133 for (std::set<Model *>::const_iterator i = m_models.begin();
134 i != m_models.end(); ++i) {
135 if (*i != dtvm && dynamic_cast<DenseTimeValueModel *>(*i)) {
136 std::cerr << "AudioCallbackPlaySource::addModel: Conflicting dense time-value model " << *i << " found" << std::endl;
137 conflicting = true;
138 break;
139 }
140 }
141
142 if (conflicting) {
143
144 std::cerr << "AudioCallbackPlaySource::addModel: ERROR: "
145 << "New model sample rate does not match" << std::endl
146 << "existing model(s) (new " << model->getSampleRate()
147 << " vs " << m_sourceSampleRate
148 << "), playback will be wrong"
149 << std::endl;
150
151 emit sampleRateMismatch(model->getSampleRate(), m_sourceSampleRate,
152 false);
153 } else {
154 m_sourceSampleRate = model->getSampleRate();
155 srChanged = true;
156 }
157 }
158 }
136 159
137 if (!m_writeBuffers || (m_writeBuffers->size() < getTargetChannelCount())) { 160 if (!m_writeBuffers || (m_writeBuffers->size() < getTargetChannelCount())) {
138 clearRingBuffers(true, getTargetChannelCount()); 161 clearRingBuffers(true, getTargetChannelCount());
139 buffersChanged = true; 162 buffersChanged = true;
140 } else { 163 } else {