changeset 287:f3b1ba71a305

* When calculating timestamps in order to write them into features that previously lacked them, from a buffering adapter, we need to take into account any timestamp adjustment used by other wrappers that are being wrapped by this one (i.e. input domain adapter)
author cannam
date Thu, 10 Sep 2009 15:21:34 +0000
parents 91574fc544db
children 283e15f6e548
files src/vamp-hostsdk/PluginBufferingAdapter.cpp
diffstat 1 files changed, 11 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/vamp-hostsdk/PluginBufferingAdapter.cpp	Thu Sep 10 13:24:26 2009 +0000
+++ b/src/vamp-hostsdk/PluginBufferingAdapter.cpp	Thu Sep 10 15:21:34 2009 +0000
@@ -39,6 +39,7 @@
 #include <map>
 
 #include <vamp-hostsdk/PluginBufferingAdapter.h>
+#include <vamp-hostsdk/PluginInputDomainAdapter.h>
 
 using std::vector;
 using std::map;
@@ -652,6 +653,14 @@
 
     FeatureSet featureSet = m_plugin->process(m_buffers, timestamp);
     
+    PluginWrapper *wrapper = dynamic_cast<PluginWrapper *>(m_plugin);
+    RealTime adjustment;
+    if (wrapper) {
+        PluginInputDomainAdapter *ida =
+            wrapper->getWrapper<PluginInputDomainAdapter>();
+        if (ida) adjustment = ida->getTimestampAdjustment();
+    }
+
     for (FeatureSet::iterator iter = featureSet.begin();
          iter != featureSet.end(); ++iter) {
 
@@ -667,14 +676,14 @@
 
                 case OutputDescriptor::OneSamplePerStep:
                     // use our internal timestamp, always
-                    featureList[i].timestamp = timestamp;
+                    featureList[i].timestamp = timestamp + adjustment;
                     featureList[i].hasTimestamp = true;
                     break;
 
                 case OutputDescriptor::FixedSampleRate:
                     // use our internal timestamp if feature lacks one
                     if (!featureList[i].hasTimestamp) {
-                        featureList[i].timestamp = timestamp;
+                        featureList[i].timestamp = timestamp + adjustment;
                         featureList[i].hasTimestamp = true;
                     }
                     break;