comparison 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
comparison
equal deleted inserted replaced
1829:51fd27fbce9a 1830:5f8fbbde08ff
28 #include <vamp-hostsdk/PluginBase.h> 28 #include <vamp-hostsdk/PluginBase.h>
29 #include "RealTimePluginInstance.h" 29 #include "RealTimePluginInstance.h"
30 30
31 #include <iostream> 31 #include <iostream>
32 32
33 PluginXml::PluginXml(Vamp::PluginBase *plugin) : 33 using std::shared_ptr;
34 using std::dynamic_pointer_cast;
35
36 PluginXml::PluginXml(shared_ptr<Vamp::PluginBase> plugin) :
34 m_plugin(plugin) 37 m_plugin(plugin)
35 { 38 {
36 } 39 }
37 40
38 PluginXml::~PluginXml() { } 41 PluginXml::~PluginXml() { }
88 stream << QString("param-%1=\"%2\" ") 91 stream << QString("param-%1=\"%2\" ")
89 .arg(stripInvalidParameterNameCharacters(QString(i->identifier.c_str()))) 92 .arg(stripInvalidParameterNameCharacters(QString(i->identifier.c_str())))
90 .arg(m_plugin->getParameter(i->identifier)); 93 .arg(m_plugin->getParameter(i->identifier));
91 } 94 }
92 95
93 RealTimePluginInstance *rtpi = 96 auto rtpi = dynamic_pointer_cast<RealTimePluginInstance>(m_plugin);
94 dynamic_cast<RealTimePluginInstance *>(m_plugin);
95 if (rtpi) { 97 if (rtpi) {
96 std::map<std::string, std::string> configurePairs = 98 std::map<std::string, std::string> configurePairs =
97 rtpi->getConfigurePairs(); 99 rtpi->getConfigurePairs();
98 QString config; 100 QString config;
99 for (std::map<std::string, std::string>::iterator i = configurePairs.begin(); 101 for (std::map<std::string, std::string>::iterator i = configurePairs.begin();
136 int version = attrs.value("version").trimmed().toInt(&ok); 138 int version = attrs.value("version").trimmed().toInt(&ok);
137 if (ok && version != m_plugin->getPluginVersion()) { 139 if (ok && version != m_plugin->getPluginVersion()) {
138 cerr << "WARNING: PluginXml::setParameters: Plugin version does not match (attributes have " << version << ", my version is " << m_plugin->getPluginVersion() << ")" << endl; 140 cerr << "WARNING: PluginXml::setParameters: Plugin version does not match (attributes have " << version << ", my version is " << m_plugin->getPluginVersion() << ")" << endl;
139 } 141 }
140 142
141 RealTimePluginInstance *rtpi = 143 auto rtpi = dynamic_pointer_cast<RealTimePluginInstance>(m_plugin);
142 dynamic_cast<RealTimePluginInstance *>(m_plugin);
143 if (rtpi) { 144 if (rtpi) {
144 QString config = attrs.value("configuration"); 145 QString config = attrs.value("configuration");
145 if (config != "") { 146 if (config != "") {
146 QStringList configList = config.split(";"); 147 QStringList configList = config.split(";");
147 for (QStringList::iterator i = configList.begin(); 148 for (QStringList::iterator i = configList.begin();