changeset 178:3e5a32a2acf4

* Ensure transformed version of a model is the same duration as the original model (don't end it when the input data runs out, as was previously done, because this will result in too short a model when latency compensation is used)
author Chris Cannam
date Wed, 05 Sep 2007 15:18:15 +0000
parents 5bde373ad5ca
children dab257bd9d2d
files transform/RealTimePluginTransform.cpp
diffstat 1 files changed, 4 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/transform/RealTimePluginTransform.cpp	Thu Aug 16 16:47:07 2007 +0000
+++ b/transform/RealTimePluginTransform.cpp	Wed Sep 05 15:18:15 2007 +0000
@@ -150,7 +150,7 @@
 
     size_t latency = m_plugin->getLatency();
 
-    while (blockFrame < endFrame && !m_abandoned) {
+    while (blockFrame < endFrame + latency && !m_abandoned) {
 
 	size_t completion =
 	    (((blockFrame - startFrame) / blockSize) * 99) /
@@ -222,7 +222,9 @@
             if (outbufs) {
 
                 if (blockFrame >= latency) {
-                    wwfm->addSamples(outbufs, blockSize);
+                    size_t writeSize = std::min(blockSize,
+                                                endFrame + latency - blockFrame);
+                    wwfm->addSamples(outbufs, writeSize);
                 } else if (blockFrame + blockSize >= latency) {
                     size_t offset = latency - blockFrame;
                     size_t count = blockSize - offset;