From e487814e9dc52b712d7c5cd242ce4fac76397b1a Mon Sep 17 00:00:00 2001 From: "Michael R. Fisher" Date: Sun, 14 Jul 2013 21:19:59 -0500 Subject: Lazily load bundled LV2 plugins in LV2PluginInfo::discover() - Do this instead of finding them in the static ctor of LV2World - Prevents usage of ARDOUR_DLL_PATH environment variable before it is set in main(...) --- libs/ardour/lv2_plugin.cc | 49 ++++++++++++++++++++++++++++++----------------- 1 file changed, 31 insertions(+), 18 deletions(-) (limited to 'libs/ardour/lv2_plugin.cc') diff --git a/libs/ardour/lv2_plugin.cc b/libs/ardour/lv2_plugin.cc index d49f8412b7..6d4a71869f 100644 --- a/libs/ardour/lv2_plugin.cc +++ b/libs/ardour/lv2_plugin.cc @@ -112,6 +112,8 @@ public: LV2World (); ~LV2World (); + void load_bundled_plugins(); + LilvWorld* world; LilvNode* atom_AtomPort; @@ -140,6 +142,9 @@ public: LilvNode* time_Position; LilvNode* ui_GtkUI; LilvNode* ui_external; + +private: + bool _bundle_checked; }; static LV2World _world; @@ -1903,27 +1908,10 @@ static bool lv2_filter (const string& str, void *arg) LV2World::LV2World() : world(lilv_world_new()) + , _bundle_checked(false) { lilv_world_load_all(world); - cout << "Scanning folders for bundled LV2s: " << ARDOUR::lv2_bundled_search_path().to_string() << endl; - PathScanner scanner; - vector *plugin_objects = scanner (ARDOUR::lv2_bundled_search_path().to_string(), lv2_filter, 0, true, true); - if (plugin_objects) { - for ( vector::iterator x = plugin_objects->begin(); x != plugin_objects->end (); ++x) { -#ifdef WINDOWS - string uri = "file:///" + **x + "/"; -#else - string uri = "file://" + **x + "/"; -#endif - LilvNode *node = lilv_new_uri(world, uri.c_str()); - lilv_world_load_bundle(world, node); - lilv_node_free(node); - } - } - delete (plugin_objects); - - atom_AtomPort = lilv_new_uri(world, LV2_ATOM__AtomPort); atom_Chunk = lilv_new_uri(world, LV2_ATOM__Chunk); atom_Sequence = lilv_new_uri(world, LV2_ATOM__Sequence); @@ -1982,6 +1970,29 @@ LV2World::~LV2World() lilv_node_free(atom_AtomPort); } +void +LV2World::load_bundled_plugins() +{ + if (!_bundle_checked) { + cout << "Scanning folders for bundled LV2s: " << ARDOUR::lv2_bundled_search_path().to_string() << endl; + PathScanner scanner; + vector *plugin_objects = scanner (ARDOUR::lv2_bundled_search_path().to_string(), lv2_filter, 0, true, true); + if (plugin_objects) { + for ( vector::iterator x = plugin_objects->begin(); x != plugin_objects->end (); ++x) { +#ifdef WINDOWS + string uri = "file:///" + **x + "/"; +#else + string uri = "file://" + **x + "/"; +#endif + LilvNode *node = lilv_new_uri(world, uri.c_str()); + lilv_world_load_bundle(world, node); + lilv_node_free(node); + } + } + delete (plugin_objects); + } +} + LV2PluginInfo::LV2PluginInfo (const void* c_plugin) : _c_plugin(c_plugin) { @@ -2013,6 +2024,8 @@ LV2PluginInfo::load(Session& session) PluginInfoList* LV2PluginInfo::discover() { + _world.load_bundled_plugins(); + PluginInfoList* plugs = new PluginInfoList; const LilvPlugins* plugins = lilv_world_get_all_plugins(_world.world); -- cgit v1.2.3 From be44b3c37b572a02cb4607c0da4fb62791bb3dad Mon Sep 17 00:00:00 2001 From: "Michael R. Fisher" Date: Sun, 14 Jul 2013 21:22:34 -0500 Subject: set the flag true --- libs/ardour/lv2_plugin.cc | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'libs/ardour/lv2_plugin.cc') diff --git a/libs/ardour/lv2_plugin.cc b/libs/ardour/lv2_plugin.cc index 6d4a71869f..df33e6c38d 100644 --- a/libs/ardour/lv2_plugin.cc +++ b/libs/ardour/lv2_plugin.cc @@ -1980,16 +1980,18 @@ LV2World::load_bundled_plugins() if (plugin_objects) { for ( vector::iterator x = plugin_objects->begin(); x != plugin_objects->end (); ++x) { #ifdef WINDOWS - string uri = "file:///" + **x + "/"; + string uri = "file:///" + **x + "/"; #else - string uri = "file://" + **x + "/"; + string uri = "file://" + **x + "/"; #endif - LilvNode *node = lilv_new_uri(world, uri.c_str()); - lilv_world_load_bundle(world, node); - lilv_node_free(node); - } + LilvNode *node = lilv_new_uri(world, uri.c_str()); + lilv_world_load_bundle(world, node); + lilv_node_free(node); } + } delete (plugin_objects); + + _bundle_checked = true; } } -- cgit v1.2.3 From 9cb678ebcc2ca0c7993bdd182c9e6ad1f8adf09a Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 15 Jul 2013 22:23:16 -0400 Subject: finally get to the bottom of where NO_PLUGIN_STATE needs to be in order to be useful --- libs/ardour/audio_unit.cc | 2 ++ libs/ardour/ladspa_plugin.cc | 10 ++++++++++ libs/ardour/lv2_plugin.cc | 3 +++ libs/ardour/plugin_insert.cc | 6 ++++++ libs/ardour/route.cc | 24 +++--------------------- libs/ardour/vst_plugin.cc | 4 +++- 6 files changed, 27 insertions(+), 22 deletions(-) (limited to 'libs/ardour/lv2_plugin.cc') diff --git a/libs/ardour/audio_unit.cc b/libs/ardour/audio_unit.cc index 0e9a11e6df..20a55e49f9 100644 --- a/libs/ardour/audio_unit.cc +++ b/libs/ardour/audio_unit.cc @@ -1717,6 +1717,7 @@ AUPlugin::set_state(const XMLNode& node, int version) return -1; } +#ifndef NO_PLUGIN_STATE if (node.children().empty()) { return -1; } @@ -1752,6 +1753,7 @@ AUPlugin::set_state(const XMLNode& node, int version) } CFRelease (propertyList); } +#endif Plugin::set_state (node, version); return ret; diff --git a/libs/ardour/ladspa_plugin.cc b/libs/ardour/ladspa_plugin.cc index cebff59771..1ab00e0b34 100644 --- a/libs/ardour/ladspa_plugin.cc +++ b/libs/ardour/ladspa_plugin.cc @@ -34,6 +34,7 @@ #include "pbd/compose.h" #include "pbd/error.h" #include "pbd/xml++.h" +#include "pbd/stacktrace.h" #include "midi++/manager.h" @@ -360,6 +361,7 @@ LadspaPlugin::set_state (const XMLNode& node, int version) return set_state_2X (node, version); } +#ifndef NO_PLUGIN_STATE XMLNodeList nodes; XMLProperty *prop; XMLNodeConstIterator iter; @@ -367,6 +369,7 @@ LadspaPlugin::set_state (const XMLNode& node, int version) const char *port; const char *data; uint32_t port_id; +#endif LocaleGuard lg (X_("POSIX")); if (node.name() != state_node_name()) { @@ -374,6 +377,8 @@ LadspaPlugin::set_state (const XMLNode& node, int version) return -1; } +#ifndef NO_PLUGIN_STATE + nodes = node.children ("Port"); for (iter = nodes.begin(); iter != nodes.end(); ++iter) { @@ -396,6 +401,7 @@ LadspaPlugin::set_state (const XMLNode& node, int version) sscanf (port, "%" PRIu32, &port_id); set_parameter (port_id, atof(data)); } +#endif latency_compute_run (); @@ -405,6 +411,7 @@ LadspaPlugin::set_state (const XMLNode& node, int version) int LadspaPlugin::set_state_2X (const XMLNode& node, int /* version */) { +#ifndef NO_PLUGIN_STATE XMLNodeList nodes; XMLProperty *prop; XMLNodeConstIterator iter; @@ -412,6 +419,7 @@ LadspaPlugin::set_state_2X (const XMLNode& node, int /* version */) const char *port; const char *data; uint32_t port_id; +#endif LocaleGuard lg (X_("POSIX")); if (node.name() != state_node_name()) { @@ -419,6 +427,7 @@ LadspaPlugin::set_state_2X (const XMLNode& node, int /* version */) return -1; } +#ifndef NO_PLUGIN_STATE nodes = node.children ("port"); for(iter = nodes.begin(); iter != nodes.end(); ++iter){ @@ -443,6 +452,7 @@ LadspaPlugin::set_state_2X (const XMLNode& node, int /* version */) } latency_compute_run (); +#endif return 0; } diff --git a/libs/ardour/lv2_plugin.cc b/libs/ardour/lv2_plugin.cc index df33e6c38d..5ea76934a5 100644 --- a/libs/ardour/lv2_plugin.cc +++ b/libs/ardour/lv2_plugin.cc @@ -1233,6 +1233,8 @@ LV2Plugin::set_state(const XMLNode& node, int version) return -1; } +#ifndef NO_PLUGIN_STATE + if (version < 3000) { nodes = node.children("port"); } else { @@ -1288,6 +1290,7 @@ LV2Plugin::set_state(const XMLNode& node, int version) } latency_compute_run(); +#endif return Plugin::set_state(node, version); } diff --git a/libs/ardour/plugin_insert.cc b/libs/ardour/plugin_insert.cc index 23cebf4276..998a03e3aa 100644 --- a/libs/ardour/plugin_insert.cc +++ b/libs/ardour/plugin_insert.cc @@ -882,7 +882,12 @@ PluginInsert::set_control_ids (const XMLNode& node, int version) if ((prop = (*iter)->property (X_("parameter"))) != 0) { uint32_t p = atoi (prop->value()); + + /* this may create the new controllable */ + boost::shared_ptr c = control (Evoral::Parameter (PluginAutomation, 0, p)); + +#ifndef NO_PLUGIN_STATE if (!c) { continue; } @@ -890,6 +895,7 @@ PluginInsert::set_control_ids (const XMLNode& node, int version) if (ac) { ac->set_state (**iter, version); } +#endif } } } diff --git a/libs/ardour/route.cc b/libs/ardour/route.cc index d48fbeff96..dad1922488 100644 --- a/libs/ardour/route.cc +++ b/libs/ardour/route.cc @@ -2558,27 +2558,9 @@ Route::set_processor_state (const XMLNode& node) continue; } - if (boost::dynamic_pointer_cast(processor)) { - cerr << "Working on plugin processor state for " << processor->name() << endl; -#ifndef NO_PLUGIN_STATE - cerr << "plugin state allowed\n"; - if (processor->set_state (**niter, Stateful::current_state_version) != 0) { - /* This processor could not be configured. Turn it into a UnknownProcessor */ - processor.reset (new UnknownProcessor (_session, **niter)); - } -#else - cerr << "plugin state dis-allowed\n"; - /* plugin, with NO_PLUGIN_STATE defined - * =>::set_state() not allowed. Do not - * display a message here - things will - * get too verbose. - */ -#endif - } else { - if (processor->set_state (**niter, Stateful::current_state_version) != 0) { - /* This processor could not be configured. Turn it into a UnknownProcessor */ - processor.reset (new UnknownProcessor (_session, **niter)); - } + if (processor->set_state (**niter, Stateful::current_state_version) != 0) { + /* This processor could not be configured. Turn it into a UnknownProcessor */ + processor.reset (new UnknownProcessor (_session, **niter)); } /* we have to note the monitor send here, otherwise a new one will be created diff --git a/libs/ardour/vst_plugin.cc b/libs/ardour/vst_plugin.cc index c385e71a5a..b80a594495 100644 --- a/libs/ardour/vst_plugin.cc +++ b/libs/ardour/vst_plugin.cc @@ -197,14 +197,15 @@ int VSTPlugin::set_state (const XMLNode& node, int version) { LocaleGuard lg (X_("POSIX")); + int ret = -1; if (node.name() != state_node_name()) { error << _("Bad node sent to VSTPlugin::set_state") << endmsg; return 0; } +#ifndef NO_PLUGIN_STATE XMLNode* child; - int ret = -1; if ((child = find_named_node (node, X_("chunk"))) != 0) { @@ -237,6 +238,7 @@ VSTPlugin::set_state (const XMLNode& node, int version) ret = 0; } +#endif Plugin::set_state (node, version); return ret; -- cgit v1.2.3