diff vamp-support/LoaderRequests.h @ 188:90c962b68d7f

Merge pull request #2 from piper-audio/dev/step-and-block-size Pull step & block size out into framing struct, return in config
author Chris Cannam <cannam@all-day-breakfast.com>
date Mon, 06 Feb 2017 12:04:25 +0000
parents 3eb00e5c76c4
children 52322dde68ea
line wrap: on
line diff
--- a/vamp-support/LoaderRequests.h	Fri Feb 03 13:00:42 2017 +0000
+++ b/vamp-support/LoaderRequests.h	Mon Feb 06 12:04:25 2017 +0000
@@ -130,12 +130,32 @@
 	ConfigurationResponse response;
 
 	response.plugin = req.plugin;
-    
+
+        if (req.configuration.framing.stepSize == 0 ||
+            req.configuration.framing.blockSize == 0) {
+            return response;
+        }
+
 	if (req.plugin->initialise(req.configuration.channelCount,
-				   req.configuration.stepSize,
-				   req.configuration.blockSize)) {
+				   req.configuration.framing.stepSize,
+				   req.configuration.framing.blockSize)) {
+
 	    response.outputs = req.plugin->getOutputDescriptors();
-	}
+
+            // If the Vamp plugin initialise() call succeeds, then by
+            // definition it is accepting the step and block size
+            // passed in
+            response.framing = req.configuration.framing;
+
+	} else {
+
+            // If initialise() fails, one reason could be that it
+            // didn't like the passed-in step and block size. If we
+            // return its current preferred values here, the
+            // host/client can retry with these (if they differ)
+            response.framing.stepSize = req.plugin->getPreferredStepSize();
+            response.framing.blockSize = req.plugin->getPreferredBlockSize();
+        }
 
 	return response;
     }