changeset 431:2819b5c9a395 vampipe

Use ConfigurationRequest/Response, introduce ProcessRequest/Response.
author Chris Cannam
date Wed, 18 May 2016 10:53:19 +0100
parents fbdb06ce1e9a
children 8dea61e4a7be
files src/vamp-hostsdk/PluginLoader.cpp vamp-hostsdk/PluginLoader.h vamp-hostsdk/RequestResponse.h
diffstat 3 files changed, 85 insertions(+), 29 deletions(-) [+]
line wrap: on
line diff
--- a/src/vamp-hostsdk/PluginLoader.cpp	Wed May 18 10:35:13 2016 +0100
+++ b/src/vamp-hostsdk/PluginLoader.cpp	Wed May 18 10:53:19 2016 +0100
@@ -69,7 +69,7 @@
 
     LoadResponse loadPlugin(LoadRequest req);
 
-    Plugin::OutputList configurePlugin(Plugin *plugin, PluginConfiguration config);
+    ConfigurationResponse configurePlugin(ConfigurationRequest req);
     
     PluginKey composePluginKey(string libraryName, string identifier);
 
@@ -169,10 +169,10 @@
     return m_impl->loadPlugin(req);
 }
 
-Plugin::OutputList
-PluginLoader::configurePlugin(Plugin *plugin, PluginConfiguration config)
+ConfigurationResponse
+PluginLoader::configurePlugin(ConfigurationRequest req)
 {
-    return m_impl->configurePlugin(plugin, config);
+    return m_impl->configurePlugin(req);
 }
 
 PluginLoader::PluginKey
@@ -455,26 +455,28 @@
     return response;
 }
 
-Plugin::OutputList
-PluginLoader::Impl::configurePlugin(Plugin *plugin, PluginConfiguration config)
+ConfigurationResponse
+PluginLoader::Impl::configurePlugin(ConfigurationRequest req)
 {
     for (PluginConfiguration::ParameterMap::const_iterator i =
-             config.parameterValues.begin();
-         i != config.parameterValues.end(); ++i) {
-        plugin->setParameter(i->first, i->second);
+             req.configuration.parameterValues.begin();
+         i != req.configuration.parameterValues.end(); ++i) {
+        req.plugin->setParameter(i->first, i->second);
     }
 
-    if (config.currentProgram != "") {
-        plugin->selectProgram(config.currentProgram);
+    if (req.configuration.currentProgram != "") {
+        req.plugin->selectProgram(req.configuration.currentProgram);
     }
 
-    if (plugin->initialise(config.channelCount,
-                           config.stepSize,
-                           config.blockSize)) {
-        return plugin->getOutputDescriptors();
-    } else {
-        return Plugin::OutputList();
+    ConfigurationResponse response;
+
+    if (req.plugin->initialise(req.configuration.channelCount,
+                               req.configuration.stepSize,
+                               req.configuration.blockSize)) {
+        response.outputs = req.plugin->getOutputDescriptors();
     }
+
+    return response;
 }
 
 void
--- a/vamp-hostsdk/PluginLoader.h	Wed May 18 10:35:13 2016 +0100
+++ b/vamp-hostsdk/PluginLoader.h	Wed May 18 10:53:19 2016 +0100
@@ -230,21 +230,20 @@
 
     /**
      * Configure and initialise a Vamp plugin. This applies the
-     * parameter and program settings found in the supplied
-     * PluginConfiguration structure and initialises the plugin. (Many
-     * hosts will prefer to do this themselves in stages, by calling
-     * methods on the plugin directly.)
+     * parameter and program settings found in the PluginConfiguration
+     * part of the supplied ConfigurationRequest and initialises the
+     * plugin. (Many hosts will prefer to do this themselves in
+     * stages, by calling methods on the plugin directly.)
      *
-     * Returns the result of calling getOutputDescriptors() on the
-     * configured and initialised plugin, representing the outputs of
-     * the plugin following configuration (since output ranges etc can
-     * depend on the parameters). If plugin initialisation fails,
-     * returns an empty list.
+     * Return a ConfigurationResponse containing the result of calling
+     * getOutputDescriptors() on the configured and initialised
+     * plugin, representing the outputs of the plugin following
+     * configuration (since output ranges etc can depend on the
+     * parameters). If initialisation fails, returns an empty list.
      *
-     * \see PluginConfiguration
+     * \see PluginConfiguration, ConfigurationRequest, ConfigurationResponse
      */
-    Plugin::OutputList configurePlugin(Plugin *plugin,
-                                       PluginConfiguration configuration);
+    ConfigurationResponse configurePlugin(ConfigurationRequest req);
     
     /**
      * Given a Vamp plugin library name and plugin identifier, return
--- a/vamp-hostsdk/RequestResponse.h	Wed May 18 10:35:13 2016 +0100
+++ b/vamp-hostsdk/RequestResponse.h	Wed May 18 10:53:19 2016 +0100
@@ -155,6 +155,9 @@
  * the data needed to configure a plugin after it has been loaded.
  *
  * \see PluginConfiguration, ConfigurationResponse, LoadRequest, LoadResponse
+ *
+ * \note This class was introduced in version 2.7 of the Vamp plugin
+ * SDK, along with the PluginLoader method that returns this structure.
  */
 struct ConfigurationRequest
 {
@@ -176,6 +179,9 @@
  * the output list will be empty.
  *
  * \see PluginConfiguration, ConfigurationRequest, LoadRequest, LoadResponse
+ *
+ * \note This class was introduced in version 2.7 of the Vamp plugin
+ * SDK, along with the PluginLoader method that returns this structure.
  */
 struct ConfigurationResponse
 {
@@ -186,6 +192,55 @@
     Plugin::OutputList outputs;
 };
 
+/**
+ * \class ProcessRequest RequestResponse.h <vamp-hostsdk/RequestResponse.h>
+ *
+ * A structure that bundles the necessary data for making a process
+ * call: plugin, input buffers, and timestamp. Caller retains
+ * ownership of the plugin, but the buffers are passed "by value" to
+ * avoid ownership concerns. 
+ *
+ * \see Plugin::process()
+ *
+ * \note This class was introduced in version 2.7 of the Vamp plugin
+ * SDK, but it is not currently used by the SDK. It is supplied as a
+ * convenience for code using the SDK, and for symmetry with the load
+ * and configuration request structs.
+ */
+struct ProcessRequest
+{
+public:
+    ProcessRequest() : // invalid by default
+        plugin(0) { }
+
+    Plugin *plugin;
+    RealTime timestamp;
+    std::vector<std::vector<float> > input;
+};
+
+/**
+ * \class ProcessResponse RequestResponse.h <vamp-hostsdk/RequestResponse.h>
+ *
+ * A structure that bundles the data returned by a process call and by
+ * Plugin::getRemainingFeatures(). This is simply a FeatureSet
+ * wrapper, named for symmetry with the other request-response pairs.
+ *
+ * \see Plugin::process(), Plugin::getRemainingFeatures()
+ *
+ * \note This class was introduced in version 2.7 of the Vamp plugin
+ * SDK, but it is not currently used by the SDK. It is supplied as a
+ * convenience for code using the SDK, and for symmetry with the load
+ * and configuration request structs.
+ */
+struct ProcessResponse
+{
+public:
+    ProcessResponse() // empty by default
+    { }
+
+    Plugin::FeatureSet features;
+};
+
 }
 
 }