diff src/vamp-hostsdk/PluginWrapper.cpp @ 538:8ffb8985ae8f

Add ability to disown a wrapped plugin - making it possible to use the adapters in some situations involving managed pointers that didn't work previously
author Chris Cannam
date Thu, 23 Apr 2020 11:39:34 +0100
parents 4a86f866bb6b
children
line wrap: on
line diff
--- a/src/vamp-hostsdk/PluginWrapper.cpp	Wed Apr 22 14:23:51 2020 +0100
+++ b/src/vamp-hostsdk/PluginWrapper.cpp	Thu Apr 23 11:39:34 2020 +0100
@@ -44,13 +44,22 @@
 
 PluginWrapper::PluginWrapper(Plugin *plugin) :
     Plugin(plugin->getInputSampleRate()),
-    m_plugin(plugin)
+    m_plugin(plugin),
+    m_pluginIsOwned(true)
 {
 }
 
 PluginWrapper::~PluginWrapper()
 {
-    delete m_plugin;
+    if (m_pluginIsOwned) {
+        delete m_plugin;
+    }
+}
+
+void
+PluginWrapper::disownPlugin()
+{
+    m_pluginIsOwned = false;
 }
 
 bool