changeset 210:df65480a08de

Merge branch 'master' into dev/rename-pluginstub
author Chris Cannam <cannam@all-day-breakfast.com>
date Thu, 09 Feb 2017 14:22:31 +0000
parents c67a0a945b6b (current diff) ac4f5f8ee0e7 (diff)
children d04956cc3deb
files vamp-client/CapnpRRClient.h vamp-client/PiperVampPlugin.h vamp-client/PluginClient.h vamp-client/qt/PiperAutoPlugin.h
diffstat 5 files changed, 59 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/vamp-client/CapnpRRClient.h	Thu Feb 09 13:31:46 2017 +0000
+++ b/vamp-client/CapnpRRClient.h	Thu Feb 09 14:22:31 2017 +0000
@@ -66,6 +66,16 @@
  * such as a subprocess pipe arrangement. Only one request can be
  * handled at a time. This class is thread-safe if and only if it is
  * constructed with a thread-safe SynchronousTransport implementation.
+ *
+ * This class takes Vamp-like structures (Plugin and the classes in
+ * vamp-support) and uses them to communicate with a Piper server
+ * using the Cap'n Proto serialisation of the Piper API. The transport
+ * layer (and thus the nature of the server) is defined by the
+ * SynchronousTransport passed to the constructor.
+ *
+ * This class implements both the Loader interface (which constructs
+ * PluginStub objects) and the PluginClient (which accepts PluginStubs
+ * and maps them into Piper handles).
  */
 class CapnpRRClient : public PluginClient,
                       public Loader
--- a/vamp-client/PiperVampPlugin.h	Thu Feb 09 13:31:46 2017 +0000
+++ b/vamp-client/PiperVampPlugin.h	Thu Feb 09 14:22:31 2017 +0000
@@ -50,6 +50,10 @@
 namespace piper_vamp {
 namespace client {
 
+/**
+ * PiperVampPlugin presents a Piper feature extractor in the form of a
+ * Vamp plugin.
+ */
 class PiperVampPlugin : public Vamp::Plugin
 {
     enum State {
--- a/vamp-client/PluginClient.h	Thu Feb 09 13:31:46 2017 +0000
+++ b/vamp-client/PluginClient.h	Thu Feb 09 14:22:31 2017 +0000
@@ -43,6 +43,12 @@
 
 class PiperVampPlugin;
 
+/**
+ * Interface for a client that accepts Vamp-like structures (Plugin
+ * and the classes in vamp-support) and communicates with a Piper
+ * server, using some serialisation and transport defined by the
+ * specific implementation.
+ */
 class PluginClient
 {
 public:
@@ -63,7 +69,8 @@
 
     virtual
     void
-    reset(PiperVampPlugin *plugin, PluginConfiguration config) = 0;
+    reset(PiperVampPlugin *plugin,
+          PluginConfiguration config) = 0;
 };
 
 }
--- a/vamp-client/qt/PiperAutoPlugin.h	Thu Feb 09 13:31:46 2017 +0000
+++ b/vamp-client/qt/PiperAutoPlugin.h	Thu Feb 09 14:22:31 2017 +0000
@@ -46,9 +46,26 @@
 namespace client {
 
 /**
- * This "plugin" make the Piper client abstraction behave like a local
- * Vamp plugin, with its own server that lasts only for the lifetime
- * of this plugin and serves only it.
+ * AutoPlugin presents a Piper feature extractor in the form of a Vamp
+ * plugin, managing its own single-use server instance. That is, the
+ * distinguishing quality of AutoPlugin (in comparison with
+ * PluginStub) is that it runs and terminates its own Piper server,
+ * whose lifetime matches that of the plugin.
+ *
+ * Example usage:
+ *
+ *    Vamp::Plugin *plugin = 
+ *        new AutoPlugin("piper-server-name.exe",
+ *                       "vamp-example-plugins:zerocrossing",
+ *                       44100.0f,
+ *                       Vamp::HostExt::PluginLoader::ADAPT_ALL_SAFE,
+ *                       nullptr);
+ *    plugin->initialise(...);
+ *    plugin->process(...);       <-- in the normal way for a Vamp plugin
+ *    delete plugin;              <-- causes the server to exit
+ *
+ * AutoPlugin makes use of the Loader and PluginClient interfaces,
+ * providing them its own transport layer object for its single server.
  *
  * Note that any method may throw ServerCrashed, RequestTimedOut or
  * ProtocolError exceptions.
@@ -56,6 +73,17 @@
 class PiperAutoPlugin : public Vamp::Plugin
 {
 public:
+    /**
+     * Construct a PiperAutoPlugin that runs an instance of the Piper
+     * server with the given server name (executable path), requesting
+     * the given plugin key from the server.
+     *
+     * \param adapterFlags a bitwise OR of the values in the
+     * Vamp::HostExt::PluginLoader::AdapterFlags enumeration
+     *
+     * \param logger an optional callback for log messages. Pass a
+     * null pointer to use cerr instead.
+     */
     PiperAutoPlugin(std::string serverName,
                     std::string pluginKey,
                     float inputSampleRate,
@@ -81,6 +109,8 @@
 
     virtual ~PiperAutoPlugin() {
         delete m_plugin;
+        // The transport is a plain data member and will be deleted
+        // here, which will have the effect of terminating the server
     }
 
     bool isOK() const {
--- a/vamp-support/PluginConfiguration.h	Thu Feb 09 13:31:46 2017 +0000
+++ b/vamp-support/PluginConfiguration.h	Thu Feb 09 14:22:31 2017 +0000
@@ -81,6 +81,10 @@
     ParameterMap parameterValues;
     std::string currentProgram;
 
+    /**
+     * Extract the configuration from the given plugin (without
+     * retaining any persistent reference to the plugin itself).
+     */
     static PluginConfiguration
     fromPlugin(Vamp::Plugin *p,
 	       int channelCount,