Mercurial > hg > svcore
comparison transform/RealTimeEffectModelTransformer.cpp @ 1755:fd7f127ecd89 by-id
Don't hold on to borrowed pointer around the loop - so as to be informed when it becomes obsolete
author | Chris Cannam |
---|---|
date | Fri, 05 Jul 2019 16:55:54 +0100 |
parents | 6d09d68165a4 |
children | 5f8fbbde08ff |
comparison
equal
deleted
inserted
replaced
1754:8529763e2258 | 1755:fd7f127ecd89 |
---|---|
140 if (!input) { | 140 if (!input) { |
141 abandon(); | 141 abandon(); |
142 return; | 142 return; |
143 } | 143 } |
144 | 144 |
145 sv_samplerate_t sampleRate; | |
146 int channelCount; | |
147 sv_frame_t startFrame; | |
148 sv_frame_t endFrame; | |
149 | |
150 { // scope so as not to have this borrowed pointer retained around | |
151 // the edges of the process loop | |
152 auto input = ModelById::getAs<DenseTimeValueModel>(getInputModel()); | |
153 if (!input) { | |
154 abandon(); | |
155 return; | |
156 } | |
157 | |
158 sampleRate = input->getSampleRate(); | |
159 channelCount = input->getChannelCount(); | |
160 startFrame = input->getStartFrame(); | |
161 endFrame = input->getEndFrame(); | |
162 } | |
163 | |
145 auto stvm = ModelById::getAs<SparseTimeValueModel>(m_outputs[0]); | 164 auto stvm = ModelById::getAs<SparseTimeValueModel>(m_outputs[0]); |
146 auto wwfm = ModelById::getAs<WritableWaveFileModel>(m_outputs[0]); | 165 auto wwfm = ModelById::getAs<WritableWaveFileModel>(m_outputs[0]); |
147 | 166 |
148 if (!stvm && !wwfm) { | 167 if (!stvm && !wwfm) { |
149 return; | 168 return; |
151 | 170 |
152 if (stvm && (m_outputNo >= int(m_plugin->getControlOutputCount()))) { | 171 if (stvm && (m_outputNo >= int(m_plugin->getControlOutputCount()))) { |
153 return; | 172 return; |
154 } | 173 } |
155 | 174 |
156 sv_samplerate_t sampleRate = input->getSampleRate(); | |
157 int channelCount = input->getChannelCount(); | |
158 if (!wwfm && m_input.getChannel() != -1) channelCount = 1; | 175 if (!wwfm && m_input.getChannel() != -1) channelCount = 1; |
159 | 176 |
160 sv_frame_t blockSize = m_plugin->getBufferSize(); | 177 sv_frame_t blockSize = m_plugin->getBufferSize(); |
161 | 178 |
162 float **inbufs = m_plugin->getAudioInputBuffers(); | 179 float **inbufs = m_plugin->getAudioInputBuffers(); |
163 | |
164 sv_frame_t startFrame = input->getStartFrame(); | |
165 sv_frame_t endFrame = input->getEndFrame(); | |
166 | 180 |
167 Transform transform = m_transforms[0]; | 181 Transform transform = m_transforms[0]; |
168 | 182 |
169 RealTime contextStartRT = transform.getStartTime(); | 183 RealTime contextStartRT = transform.getStartTime(); |
170 RealTime contextDurationRT = transform.getDuration(); | 184 RealTime contextDurationRT = transform.getDuration(); |
202 int completion = int | 216 int completion = int |
203 ((((blockFrame - contextStart) / blockSize) * 99) / | 217 ((((blockFrame - contextStart) / blockSize) * 99) / |
204 (1 + ((contextDuration) / blockSize))); | 218 (1 + ((contextDuration) / blockSize))); |
205 | 219 |
206 sv_frame_t got = 0; | 220 sv_frame_t got = 0; |
221 | |
222 auto input = ModelById::getAs<DenseTimeValueModel>(getInputModel()); | |
223 if (!input) { | |
224 abandon(); | |
225 return; | |
226 } | |
207 | 227 |
208 if (channelCount == 1) { | 228 if (channelCount == 1) { |
209 if (inbufs && inbufs[0]) { | 229 if (inbufs && inbufs[0]) { |
210 auto data = input->getData | 230 auto data = input->getData |
211 (m_input.getChannel(), blockFrame, blockSize); | 231 (m_input.getChannel(), blockFrame, blockSize); |