diff vamp-sdk/hostext/PluginBufferingAdapter.cpp @ 104:08d8c8ee6097

* implement reset() in PluginBufferingAdapter
author cannam
date Thu, 31 Jan 2008 09:24:47 +0000
parents ca40f3bc99f0
children 92ca8e401044
line wrap: on
line diff
--- a/vamp-sdk/hostext/PluginBufferingAdapter.cpp	Tue Jan 29 16:13:22 2008 +0000
+++ b/vamp-sdk/hostext/PluginBufferingAdapter.cpp	Thu Jan 31 09:24:47 2008 +0000
@@ -57,6 +57,8 @@
 
     OutputList getOutputDescriptors() const;
 
+    void reset();
+
     FeatureSet process(const float *const *inputBuffers, RealTime timestamp);
 		
     FeatureSet getRemainingFeatures();
@@ -225,7 +227,8 @@
     vector<RingBuffer *> m_queue;
     float **m_buffers;
     float m_inputSampleRate;
-    RealTime m_timestamp;	
+    RealTime m_timestamp;
+    bool m_unrun;
     OutputList m_outputs;
 		
     void processBlock(FeatureSet& allFeatureSets, RealTime timestamp);
@@ -253,6 +256,12 @@
 {
     return m_impl->getOutputDescriptors();
 }
+
+void
+PluginBufferingAdapter::reset()
+{
+    m_impl->reset();
+}
 		
 PluginBufferingAdapter::FeatureSet
 PluginBufferingAdapter::process(const float *const *inputBuffers,
@@ -277,7 +286,8 @@
     m_queue(0),
     m_buffers(0),
     m_inputSampleRate(inputSampleRate),
-    m_timestamp()
+    m_timestamp(RealTime::zeroTime),
+    m_unrun(true)
 {
     m_outputs = plugin->getOutputDescriptors();
 }
@@ -365,11 +375,27 @@
     return outs;
 }
 
+void
+PluginBufferingAdapter::Impl::reset()
+{
+    m_timestamp = RealTime::zeroTime;
+    m_unrun = true;
+
+    for (size_t i = 0; i < m_queue.size(); ++i) {
+        m_queue[i]->reset();
+    }
+}
+
 PluginBufferingAdapter::FeatureSet
 PluginBufferingAdapter::Impl::process(const float *const *inputBuffers,
                                       RealTime timestamp)
 {
     FeatureSet allFeatureSets;
+
+    if (m_unrun) {
+        m_timestamp = timestamp;
+        m_unrun = false;
+    }
 			
     // queue the new input