diff vamp-client/PluginStub.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-client/PluginStub.h	Fri Feb 03 13:00:42 2017 +0000
+++ b/vamp-client/PluginStub.h	Mon Feb 06 12:04:25 2017 +0000
@@ -163,11 +163,21 @@
         }
         
         m_config.channelCount = int(inputChannels);
-        m_config.stepSize = int(stepSize);
-        m_config.blockSize = int(blockSize);
+        m_config.framing.stepSize = int(stepSize);
+        m_config.framing.blockSize = int(blockSize);
 
         try {
-            m_outputs = m_client->configure(this, m_config);
+            auto response = m_client->configure(this, m_config);
+            m_outputs = response.outputs;
+
+            // Update with the new preferred step and block size now
+            // that the plugin has taken into account its parameter
+            // settings. If the values passed in to initialise()
+            // weren't suitable, then this ensures that a subsequent
+            // call to getPreferredStepSize/BlockSize on this plugin
+            // object will at least get acceptable values from now on
+            m_config.framing = response.framing;
+            
         } catch (const std::exception &e) {
             m_state = Failed;
             throw;
@@ -206,11 +216,17 @@
     }
 
     virtual size_t getPreferredBlockSize() const {
-        return m_defaultConfig.blockSize;
+        // Return this from m_config instead of m_defaultConfig, so
+        // that it gets updated in the event of an initialise() call
+        // that fails for the wrong value
+        return m_config.framing.blockSize;
     }
 
     virtual size_t getPreferredStepSize() const {
-        return m_defaultConfig.stepSize;
+        // Return this from m_config instead of m_defaultConfig, so
+        // that it gets updated in the event of an initialise() call
+        // that fails for the wrong value
+        return m_config.framing.stepSize;
     }
 
     virtual size_t getMinChannelCount() const {
@@ -265,7 +281,7 @@
         for (int c = 0; c < m_config.channelCount; ++c) {
             vecbuf.push_back(std::vector<float>
                              (inputBuffers[c],
-                              inputBuffers[c] + m_config.blockSize));
+                              inputBuffers[c] + m_config.framing.blockSize));
         }
 
         try {