Mercurial > hg > svcore
diff transform/FeatureExtractionModelTransformer.cpp @ 497:b6dc6c7f402c
Various fixes:
* Fix handling of HTTP redirects (avoiding crashes... I hope)
* Fix failure to delete FFT models when a feature extraction model
transformer was abandoned (also a cause of crashes in the past)
* Fix deadlock when said transform was abandoned before its source
model was ready because the session was being cleared (and so the
source model would never be ready)
author | Chris Cannam |
---|---|
date | Fri, 28 Nov 2008 13:36:13 +0000 |
parents | a70dcfed59c1 |
children | 55ad231c9db7 |
line wrap: on
line diff
--- a/transform/FeatureExtractionModelTransformer.cpp Thu Nov 27 22:09:58 2008 +0000 +++ b/transform/FeatureExtractionModelTransformer.cpp Fri Nov 28 13:36:13 2008 +0000 @@ -371,10 +371,11 @@ if (!m_output) return; - while (!input->isReady()) { + while (!input->isReady() && !m_abandoned) { std::cerr << "FeatureExtractionModelTransformer::run: Waiting for input model to be ready..." << std::endl; - sleep(1); + usleep(500000); } + if (m_abandoned) return; size_t sampleRate = input->getSampleRate(); @@ -478,9 +479,13 @@ getFrames(channelCount, blockFrame, blockSize, buffers); } + if (m_abandoned) break; + Vamp::Plugin::FeatureSet features = m_plugin->process (buffers, Vamp::RealTime::frame2RealTime(blockFrame, sampleRate)); + if (m_abandoned) break; + for (size_t fi = 0; fi < features[m_outputFeatureNo].size(); ++fi) { Vamp::Plugin::Feature feature = features[m_outputFeatureNo][fi]; @@ -495,23 +500,23 @@ blockFrame += stepSize; } - if (m_abandoned) return; + if (!m_abandoned) { + Vamp::Plugin::FeatureSet features = m_plugin->getRemainingFeatures(); - Vamp::Plugin::FeatureSet features = m_plugin->getRemainingFeatures(); + for (size_t fi = 0; fi < features[m_outputFeatureNo].size(); ++fi) { + Vamp::Plugin::Feature feature = + features[m_outputFeatureNo][fi]; + addFeature(blockFrame, feature); + } + } - for (size_t fi = 0; fi < features[m_outputFeatureNo].size(); ++fi) { - Vamp::Plugin::Feature feature = - features[m_outputFeatureNo][fi]; - addFeature(blockFrame, feature); - } + setCompletion(100); if (frequencyDomain) { for (size_t ch = 0; ch < channelCount; ++ch) { delete fftModels[ch]; } } - - setCompletion(100); } void