diff plugin/PluginXml.cpp @ 1830:5f8fbbde08ff audio-source-refactor

Use shared_ptr for plugin instances throughout
author Chris Cannam
date Fri, 20 Mar 2020 16:30:33 +0000
parents 59e7fe1b1003
children
line wrap: on
line diff
--- a/plugin/PluginXml.cpp	Fri Mar 20 16:30:16 2020 +0000
+++ b/plugin/PluginXml.cpp	Fri Mar 20 16:30:33 2020 +0000
@@ -30,7 +30,10 @@
 
 #include <iostream>
 
-PluginXml::PluginXml(Vamp::PluginBase *plugin) :
+using std::shared_ptr;
+using std::dynamic_pointer_cast;
+
+PluginXml::PluginXml(shared_ptr<Vamp::PluginBase> plugin) :
     m_plugin(plugin)
 {
 }
@@ -90,8 +93,7 @@
             .arg(m_plugin->getParameter(i->identifier));
     }
 
-    RealTimePluginInstance *rtpi =
-        dynamic_cast<RealTimePluginInstance *>(m_plugin);
+    auto rtpi = dynamic_pointer_cast<RealTimePluginInstance>(m_plugin);
     if (rtpi) {
         std::map<std::string, std::string> configurePairs =
             rtpi->getConfigurePairs();
@@ -138,8 +140,7 @@
         cerr << "WARNING: PluginXml::setParameters: Plugin version does not match (attributes have " << version << ", my version is " << m_plugin->getPluginVersion() << ")" << endl;
     }
 
-    RealTimePluginInstance *rtpi =
-        dynamic_cast<RealTimePluginInstance *>(m_plugin);
+    auto rtpi = dynamic_pointer_cast<RealTimePluginInstance>(m_plugin);
     if (rtpi) {
         QString config = attrs.value("configuration");
         if (config != "") {