Mercurial > hg > svcore
diff transform/FeatureExtractionModelTransformer.cpp @ 1757:776389390473 by-id
Merge
author | Chris Cannam |
---|---|
date | Sat, 06 Jul 2019 18:12:54 +0100 |
parents | fd7f127ecd89 |
children | 110f853c3149 |
line wrap: on
line diff
--- a/transform/FeatureExtractionModelTransformer.cpp Sat Jul 06 18:12:38 2019 +0100 +++ b/transform/FeatureExtractionModelTransformer.cpp Sat Jul 06 18:12:54 2019 +0100 @@ -648,17 +648,29 @@ if (m_abandoned) return; ModelId inputId = getInputModel(); - auto input = ModelById::getAs<DenseTimeValueModel>(inputId); - if (!input) { - abandon(); - return; - } - sv_samplerate_t sampleRate = input->getSampleRate(); + sv_samplerate_t sampleRate; + int channelCount; + sv_frame_t startFrame; + sv_frame_t endFrame; + + { // scope so as not to have this borrowed pointer retained around + // the edges of the process loop + auto input = ModelById::getAs<DenseTimeValueModel>(inputId); + if (!input) { + abandon(); + return; + } - int channelCount = input->getChannelCount(); - if ((int)m_plugin->getMaxChannelCount() < channelCount) { - channelCount = 1; + sampleRate = input->getSampleRate(); + + channelCount = input->getChannelCount(); + if ((int)m_plugin->getMaxChannelCount() < channelCount) { + channelCount = 1; + } + + startFrame = input->getStartFrame(); + endFrame = input->getEndFrame(); } float **buffers = new float*[channelCount]; @@ -696,9 +708,6 @@ } } - sv_frame_t startFrame = input->getStartFrame(); - sv_frame_t endFrame = input->getEndFrame(); - RealTime contextStartRT = primaryTransform.getStartTime(); RealTime contextDurationRT = primaryTransform.getDuration(); @@ -761,6 +770,11 @@ ((((blockFrame - contextStart) / stepSize) * 99) / (contextDuration / stepSize + 1)); + if (!ModelById::get(inputId)) { + abandon(); + return; + } + // channelCount is either input->channelCount or 1 if (frequencyDomain) {