# HG changeset patch
# User Chris Cannam
# Date 1412790280 -3600
# Node ID b514bae9555e7583c5208c56a8083e2d023fd77a
# Parent  eb0f3a2029b8c9c700dad318ba7f4234167a2f6e
Do not feed audio data to a plugin before its transform's start time (we might be feeding other transforms that started earlier). This breaks a test, but the test's expected output was broken (rather alarmingly)! Note that this does mean a plugin may have to-next-block "leakage" at start as well as end of its start-duration zone.

diff -r eb0f3a2029b8 -r b514bae9555e runner/FeatureExtractionManager.cpp
--- a/runner/FeatureExtractionManager.cpp	Wed Oct 08 15:38:48 2014 +0100
+++ b/runner/FeatureExtractionManager.cpp	Wed Oct 08 18:44:40 2014 +0100
@@ -766,6 +766,27 @@
         foreach (Plugin *plugin, m_orderedPlugins) {
 
             PluginMap::iterator pi = m_plugins.find(plugin);
+
+            // Skip any plugin none of whose transforms have come
+            // around yet. (Though actually, all transforms for a
+            // given plugin must have the same start time -- they can
+            // only differ in output and summary type.)
+            bool inRange = false;
+            for (TransformWriterMap::const_iterator ti = pi->second.begin();
+                 ti != pi->second.end(); ++ti) {
+                int startFrame = RealTime::realTime2Frame
+                    (ti->first.getStartTime(), m_sampleRate);
+                cerr << "plugin " << plugin << " transform " << &(ti->first) << " start frame " << startFrame << " my frame " << i << endl;
+                if (i >= startFrame || i + m_blockSize > startFrame) {
+                    inRange = true;
+                    break;
+                }
+            }
+            if (!inRange) {
+                cerr << "not in range! plugging on" << endl;
+                continue;
+            }
+
             Plugin::FeatureSet featureSet = plugin->process(data, timestamp);
 
             if (!m_summariesOnly) {