X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fardour%2Fplugin.cc;h=9bbe21aabf652ebe6d300979636c85cdaba7f92f;hb=db6706429643d80e68a050daa015d17f36d5321b;hp=f69de57b9972cf8aeab6b036f3fd05c86b1541a7;hpb=e0aaed6d65f160c328cb8b56d7c6552ee15d65e2;p=ardour.git diff --git a/libs/ardour/plugin.cc b/libs/ardour/plugin.cc index f69de57b99..9bbe21aabf 100644 --- a/libs/ardour/plugin.cc +++ b/libs/ardour/plugin.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2000-2002 Paul Davis + Copyright (C) 2000-2002 Paul Davis This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -17,6 +17,10 @@ */ +#ifdef WAF_BUILD +#include "libardour-config.h" +#endif + #include #include @@ -54,16 +58,25 @@ #include "i18n.h" #include +using namespace std; using namespace ARDOUR; using namespace PBD; Plugin::Plugin (AudioEngine& e, Session& s) - : _engine (e), _session (s) + : _engine (e) + , _session (s) + , _cycles (0) { } Plugin::Plugin (const Plugin& other) - : _engine (other._engine), _session (other._session), _info (other._info) + : StatefulDestructible() + , Latent() + , _engine (other._engine) + , _session (other._session) + , _info (other._info) + , _cycles (0) + , presets (other.presets) { } @@ -101,7 +114,7 @@ Plugin::get_presets() uint32_t id; std::string unique (unique_id()); - /* XXX problem: AU plugins don't have numeric ID's. + /* XXX problem: AU plugins don't have numeric ID's. Solution: they have a different method of providing presets. XXX sub-problem: implement it. */ @@ -129,13 +142,13 @@ Plugin::get_presets() } bool -Plugin::load_preset(const string preset_uri) +Plugin::load_preset(const string& preset_uri) { lrdf_defaults* defs = lrdf_get_setting_values(preset_uri.c_str()); if (defs) { for (uint32_t i = 0; i < (uint32_t) defs->count; ++i) { - // The defs->items[i].pid < defs->count check is to work around + // The defs->items[i].pid < defs->count check is to work around // a bug in liblrdf that saves invalid values into the presets file. if (((uint32_t) defs->items[i].pid < (uint32_t) defs->count) && parameter_is_input (defs->items[i].pid)) { set_parameter(defs->items[i].pid, defs->items[i].value); @@ -148,14 +161,14 @@ Plugin::load_preset(const string preset_uri) } bool -Plugin::save_preset (string uri, string domain) +Plugin::save_preset (string name, string domain) { lrdf_portvalue portvalues[parameter_count()]; lrdf_defaults defaults; uint32_t id; std::string unique (unique_id()); - /* XXX problem: AU plugins don't have numeric ID's. + /* XXX problem: AU plugins don't have numeric ID's. Solution: they have a different method of providing/saving presets. XXX sub-problem: implement it. */ @@ -181,28 +194,28 @@ Plugin::save_preset (string uri, string domain) warning << _("Could not locate HOME. Preset not saved.") << endmsg; return false; } - + string source(string_compose("file:%1/.%2/rdf/ardour-presets.n3", envvar, domain)); - map::const_iterator pr = presets.find(uri); - if (pr == presets.end()) { - warning << _("Could not find preset ") << uri << endmsg; - return false; - } - free(lrdf_add_preset(source.c_str(), pr->second.label.c_str(), id, &defaults)); + char* uri = lrdf_add_preset (source.c_str(), name.c_str(), id, &defaults); + + /* XXX: why is the uri apparently kept as the key in the `presets' map and also in the PresetRecord? */ + + presets.insert (make_pair (uri, PresetRecord (uri, name))); + free (uri); string path = string_compose("%1/.%2", envvar, domain); if (g_mkdir_with_parents (path.c_str(), 0775)) { warning << string_compose(_("Could not create %1. Preset not saved. (%2)"), path, strerror(errno)) << endmsg; return false; } - + path += "/rdf"; if (g_mkdir_with_parents (path.c_str(), 0775)) { warning << string_compose(_("Could not create %1. Preset not saved. (%2)"), path, strerror(errno)) << endmsg; return false; } - + if (lrdf_export_by_source(source.c_str(), source.substr(5).c_str())) { warning << string_compose(_("Error saving presets file %1."), source) << endmsg; return false; @@ -221,7 +234,7 @@ ARDOUR::find_plugin(Session& session, string identifier, PluginType type) case ARDOUR::LADSPA: plugs = mgr->ladspa_plugin_info(); break; - + #ifdef HAVE_SLV2 case ARDOUR::LV2: plugs = mgr->lv2_plugin_info(); @@ -264,7 +277,7 @@ ARDOUR::find_plugin(Session& session, string identifier, PluginType type) } } #endif - + return PluginPtr ((Plugin*) 0); }