changeset 386:e0697515163f

Fine adjustment to timestamp to avoid rounding error
author Chris Cannam
date Wed, 14 Jan 2015 16:58:53 +0000
parents 632d90c185ec
children 3cd80757becf 4ec736a36546
files src/vamp-hostsdk/PluginInputDomainAdapter.cpp
diffstat 1 files changed, 7 insertions(+), 0 deletions(-) [+]
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) {