13
0

Added the property "unique-id" to PluginInserts so that ladspa plugins

will be loaded by their UID instead of their name.


git-svn-id: svn://localhost/trunk/ardour2@285 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Sampo Savolainen 2006-01-22 00:08:38 +00:00
parent 897d071e97
commit 860749eb13
3 changed files with 27 additions and 5 deletions

View File

@ -54,7 +54,7 @@ class PluginInfo {
PluginInfo () { };
PluginInfo (const PluginInfo &o)
: name(o.name), n_inputs(o.n_inputs), n_outputs(o.n_outputs),
path (o.path), index(o.index) {}
unique_id(o.unique_id), path (o.path), index(o.index) {}
~PluginInfo () { };
string name;
string category;
@ -62,6 +62,8 @@ class PluginInfo {
uint32_t n_outputs;
Type type;
long unique_id;
private:
friend class PluginManager;
string path;
@ -185,7 +187,7 @@ class Plugin : public Stateful, public sigc::trackable
/* this is actually defined in plugin_manager.cc */
Plugin * find_plugin(ARDOUR::Session&, string name, PluginInfo::Type);
Plugin * find_plugin(ARDOUR::Session&, string name, long unique_id, PluginInfo::Type);
} // namespace ARDOUR

View File

@ -597,6 +597,11 @@ PluginInsert::state (bool full)
node->add_property ("type", _plugins[0]->state_node_name());
snprintf(buf, sizeof(buf), "%s", _plugins[0]->name());
node->add_property("id", string(buf));
if (_plugins[0]->state_node_name() == "ladspa") {
char buf[32];
snprintf (buf, 31, "%d", _plugins[0]->get_info().unique_id);
node->add_property("unique-id", string(buf));
}
node->add_property("count", string_compose("%1", _plugins.size()));
node->add_child_nocopy (_plugins[0]->get_state());
@ -632,6 +637,7 @@ PluginInsert::set_state(const XMLNode& node)
XMLNodeIterator niter;
XMLPropertyList plist;
const XMLProperty *prop;
long unique = 0;
PluginInfo::Type type;
if ((prop = node.property ("type")) == 0) {
@ -650,6 +656,11 @@ PluginInsert::set_state(const XMLNode& node)
return -1;
}
prop = node.property ("unique-id");
if (prop != 0) {
unique = atol(prop->value().c_str());
}
if ((prop = node.property ("id")) == 0) {
error << _("XML node describing insert is missing the `id' field") << endmsg;
return -1;
@ -657,7 +668,13 @@ PluginInsert::set_state(const XMLNode& node)
Plugin* plugin;
if ((plugin = find_plugin (_session, prop->value(), type)) == 0) {
if (unique != 0) {
plugin = find_plugin (_session, "", unique, type);
} else {
plugin = find_plugin (_session, prop->value(), 0, type);
}
if (plugin == 0) {
error << string_compose(_("Found a reference to a plugin (\"%1\") that is unknown.\n"
"Perhaps it was removed or moved since it was last used."), prop->value())
<< endmsg;

View File

@ -258,6 +258,7 @@ PluginManager::ladspa_discover (string path)
info->n_inputs = 0;
info->n_outputs = 0;
info->type = PluginInfo::LADSPA;
info->unique_id = descriptor->UniqueID;
for (uint32_t n=0; n < descriptor->PortCount; ++n) {
if ( LADSPA_IS_PORT_AUDIO (descriptor->PortDescriptors[n]) ) {
@ -326,7 +327,7 @@ PluginManager::load (Session& session, PluginInfo *info)
}
Plugin *
ARDOUR::find_plugin(Session& session, string name, PluginInfo::Type type)
ARDOUR::find_plugin(Session& session, string name, long unique_id, PluginInfo::Type type)
{
PluginManager *mgr = PluginManager::the_manager();
list<PluginInfo *>::iterator i;
@ -338,11 +339,13 @@ ARDOUR::find_plugin(Session& session, string name, PluginInfo::Type type)
break;
case PluginInfo::VST:
plugs = &mgr->vst_plugin_info();
unique_id = 0; // VST plugins don't have a unique id.
break;
}
for (i = plugs->begin(); i != plugs->end(); ++i) {
if ((*i)->name == name) {
if ((name == "" || (*i)->name == name) &&
(unique_id == 0 || (*i)->unique_id == unique_id)) {
return mgr->load (session, *i);
}
}