Mercurial > hg > svcore
diff plugin/PluginXml.cpp @ 75:163f3428bbe0
* Create temporary directory, cleaned up on exit, and use it to store
(inter alia) audio samples for the sample-player plugin.
* Ensure newly added layers always have unique names
* Make sure configure pairs for real-time plugins are stored in the
configuration Xml along with parameter & program settings
author | Chris Cannam |
---|---|
date | Mon, 10 Apr 2006 13:52:32 +0000 |
parents | 7afcfe666910 |
children | f277a171749d |
line wrap: on
line diff
--- a/plugin/PluginXml.cpp Fri Apr 07 17:50:33 2006 +0000 +++ b/plugin/PluginXml.cpp Mon Apr 10 13:52:32 2006 +0000 @@ -24,6 +24,7 @@ #include <QDomAttr> #include "vamp-sdk/PluginBase.h" +#include "RealTimePluginInstance.h" #include <iostream> @@ -63,6 +64,29 @@ .arg(m_plugin->getParameter(i->name)); } + RealTimePluginInstance *rtpi = + dynamic_cast<RealTimePluginInstance *>(m_plugin); + if (rtpi) { + std::map<std::string, std::string> configurePairs = + rtpi->getConfigurePairs(); + QString config; + for (std::map<std::string, std::string>::iterator i = configurePairs.begin(); + i != configurePairs.end(); ++i) { + QString key = i->first.c_str(); + QString value = i->second.c_str(); + key.replace(";", "[[SEMICOLON]]"); + key.replace("=", "[[EQUALS]]"); + value.replace(";", "[[SEMICOLON]]"); + value.replace("=", "[[EQUALS]]"); + if (config != "") config += ";"; + config += QString("%1=%2").arg(key).arg(value); + } + if (config != "") { + s += QString("configuration=\"%1\" ") + .arg(encodeEntities(config)); + } + } + s += "/>\n"; return s; } @@ -90,6 +114,29 @@ std::cerr << "WARNING: PluginXml::setParameters: Plugin version does not match (attributes have " << version << ", my version is " << m_plugin->getPluginVersion() << ")" << std::endl; } + RealTimePluginInstance *rtpi = + dynamic_cast<RealTimePluginInstance *>(m_plugin); + if (rtpi) { + QString config = attrs.value("configuration"); + if (config != "") { + QStringList configList = config.split(";"); + for (QStringList::iterator i = configList.begin(); + i != configList.end(); ++i) { + QStringList kv = i->split("="); + if (kv.count() < 2) { + std::cerr << "WARNING: PluginXml::setParameters: Malformed configure pair string: \"" << i->toStdString() << "\"" << std::endl; + continue; + } + QString key(kv[0]), value(kv[1]); + key.replace("[[SEMICOLON]]", ";"); + key.replace("[[EQUALS]]", ";"); + value.replace("[[SEMICOLON]]", ";"); + value.replace("[[SEMICOLON]]", ";"); + rtpi->configure(key.toStdString(), value.toStdString()); + } + } + } + if (!m_plugin->getPrograms().empty()) { m_plugin->selectProgram(attrs.value("program").toStdString()); }