changeset 113:00221fb5b9d2

Ensure finish() can be called even if not configured (otherwise there's no way to dispose of the plugin)
author Chris Cannam <c.cannam@qmul.ac.uk>
date Tue, 11 Oct 2016 14:37:12 +0100
parents 19e47ffed525
children c14520102b46
files PiperPluginLibrary.cpp
diffstat 1 files changed, 8 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/PiperPluginLibrary.cpp	Mon Oct 10 17:05:37 2016 +0100
+++ b/PiperPluginLibrary.cpp	Tue Oct 11 14:37:12 2016 +0100
@@ -292,13 +292,18 @@
             auto h = m_mapper.pluginToHandle(req.plugin);
             if (h == m_mapper.INVALID_HANDLE) {
                 rj = VampJson::fromError("unknown or invalid plugin handle", type, id);
-            } else if (!m_mapper.isConfigured(h)) {
-                rj = VampJson::fromError("plugin has not been configured", type, id);
             } else {
 
                 Vamp::HostExt::ProcessResponse resp;
                 resp.plugin = req.plugin;
-                resp.features = req.plugin->getRemainingFeatures();
+
+                // Finish can be called (to unload the plugin) even if
+                // the plugin has never been configured or used. But
+                // we want to make sure we call getRemainingFeatures
+                // only if we have actually configured the plugin.
+                if (m_mapper.isConfigured(h)) {
+                    resp.features = req.plugin->getRemainingFeatures();
+                }
 
                 rj = VampJson::fromRpcResponse_Finish
                     (resp, m_mapper, serialisation, id);