diff src/vamp-hostsdk/PluginInputDomainAdapter.cpp @ 386:e0697515163f

Fine adjustment to timestamp to avoid rounding error
author Chris Cannam
date Wed, 14 Jan 2015 16:58:53 +0000
parents 364e4653fe20
children 35fa4733bc5d
line wrap: on
line diff
--- a/src/vamp-hostsdk/PluginInputDomainAdapter.cpp	Thu Oct 16 10:50:20 2014 +0100
+++ b/src/vamp-hostsdk/PluginInputDomainAdapter.cpp	Wed Jan 14 16:58:53 2015 +0000
@@ -508,7 +508,14 @@
                                                          RealTime timestamp)
 {
     if (m_method == ShiftTimestamp) {
+        // we may need to add one nsec if timestamp +
+        // getTimestampAdjustment() rounds down
         timestamp = timestamp + getTimestampAdjustment();
+        RealTime nsec(0, 1);
+        if (RealTime::realTime2Frame(timestamp, m_inputSampleRate) <
+            RealTime::realTime2Frame(timestamp + nsec, m_inputSampleRate)) {
+            timestamp = timestamp + nsec;
+        }
     }
 
     for (int c = 0; c < m_channels; ++c) {