From: Robin Gareus Date: Sat, 9 Jan 2016 14:22:16 +0000 (+0100) Subject: API evolution X-Git-Tag: 4.5~10 X-Git-Url: https://main.carlh.net/gitweb/?p=ardour.git;a=commitdiff_plain;h=e6e7377cd8596f8ed8b5d39634e550a05995999b API evolution The Session-reference is only needed to instantiate/load the plugin. Indexing presets is not supposed to call load() and be const WRT to PluginInfo --- diff --git a/libs/ardour/ardour/audio_unit.h b/libs/ardour/ardour/audio_unit.h index c495f010b3..e9a5622ea9 100644 --- a/libs/ardour/ardour/audio_unit.h +++ b/libs/ardour/ardour/audio_unit.h @@ -232,7 +232,7 @@ class LIBARDOUR_API AUPluginInfo : public PluginInfo { PluginPtr load (Session& session); - virtual std::vector get_presets(Session& session); + std::vector get_presets (bool user_only) const; bool needs_midi_input (); bool is_effect () const; diff --git a/libs/ardour/ardour/ladspa_plugin.h b/libs/ardour/ardour/ladspa_plugin.h index 3336a31bf4..6fd214db68 100644 --- a/libs/ardour/ardour/ladspa_plugin.h +++ b/libs/ardour/ardour/ladspa_plugin.h @@ -151,7 +151,7 @@ class LIBARDOUR_API LadspaPluginInfo : public PluginInfo { ~LadspaPluginInfo () { }; PluginPtr load (Session& session); - virtual std::vector get_presets(Session& session); + std::vector get_presets (bool user_only) const; }; typedef boost::shared_ptr LadspaPluginInfoPtr; diff --git a/libs/ardour/ardour/lv2_plugin.h b/libs/ardour/ardour/lv2_plugin.h index 093d77817b..a4cdfcd036 100644 --- a/libs/ardour/ardour/lv2_plugin.h +++ b/libs/ardour/ardour/lv2_plugin.h @@ -281,7 +281,7 @@ public: static PluginInfoList* discover (); PluginPtr load (Session& session); - virtual std::vector get_presets(Session& session); + std::vector get_presets (bool user_only) const; virtual bool in_category (const std::string &c) const; virtual bool is_instrument() const; diff --git a/libs/ardour/ardour/lxvst_plugin.h b/libs/ardour/ardour/lxvst_plugin.h index d58bc63d06..5a35d9832e 100644 --- a/libs/ardour/ardour/lxvst_plugin.h +++ b/libs/ardour/ardour/lxvst_plugin.h @@ -47,7 +47,7 @@ class LIBARDOUR_API LXVSTPluginInfo : public PluginInfo ~LXVSTPluginInfo () {} PluginPtr load (Session& session); - virtual std::vector get_presets(Session&); + std::vector get_presets (bool user_only) const; }; } // namespace ARDOUR diff --git a/libs/ardour/ardour/plugin.h b/libs/ardour/ardour/plugin.h index 07297c8cad..44090c3aea 100644 --- a/libs/ardour/ardour/plugin.h +++ b/libs/ardour/ardour/plugin.h @@ -336,7 +336,7 @@ class LIBARDOUR_API PluginInfo { virtual bool is_instrument() const; virtual bool in_category (const std::string &) const { return false; } - virtual std::vector get_presets(Session& session) = 0; + virtual std::vector get_presets (bool user_only) const = 0; /* NOTE: this block of virtual methods looks like the interface to a Processor, but Plugin does not inherit from Processor. diff --git a/libs/ardour/ardour/windows_vst_plugin.h b/libs/ardour/ardour/windows_vst_plugin.h index c76bc13b46..7566eab098 100644 --- a/libs/ardour/ardour/windows_vst_plugin.h +++ b/libs/ardour/ardour/windows_vst_plugin.h @@ -47,7 +47,7 @@ public: ~WindowsVSTPluginInfo () {} PluginPtr load (Session& session); - virtual std::vector get_presets(Session&); + std::vector get_presets (bool user_only) const; }; } // namespace ARDOUR diff --git a/libs/ardour/audio_unit.cc b/libs/ardour/audio_unit.cc index 88bd981560..1c482736b8 100644 --- a/libs/ardour/audio_unit.cc +++ b/libs/ardour/audio_unit.cc @@ -2384,7 +2384,7 @@ AUPluginInfo::load (Session& session) } std::vector -AUPluginInfo::get_presets(Session& session) +AUPluginInfo::get_presets (bool user_only) const { std::vector p; boost::shared_ptr comp; @@ -2422,7 +2422,10 @@ AUPluginInfo::get_presets(Session& session) } } -#if 0 // don't include factory presets in the sidebar, for now + if (user_only) { + return p; + } + // factory presets CFArrayRef presets; @@ -2455,7 +2458,6 @@ AUPluginInfo::get_presets(Session& session) } CFRelease (presets); unit->Uninitialize (); -#endif // factory presets #endif // NO_PLUGIN_STATE return p; diff --git a/libs/ardour/ladspa_plugin.cc b/libs/ardour/ladspa_plugin.cc index 6ec0723248..f30925ac51 100644 --- a/libs/ardour/ladspa_plugin.cc +++ b/libs/ardour/ladspa_plugin.cc @@ -739,7 +739,7 @@ LadspaPluginInfo::load (Session& session) } std::vector -LadspaPluginInfo::get_presets(Session& session) +LadspaPluginInfo::get_presets (bool /*user_only*/) const { std::vector p; #if (defined HAVE_LRDF && !defined NO_PLUGIN_STATE) diff --git a/libs/ardour/lv2_plugin.cc b/libs/ardour/lv2_plugin.cc index e405b1a1cd..c39e40c7d5 100644 --- a/libs/ardour/lv2_plugin.cc +++ b/libs/ardour/lv2_plugin.cc @@ -2624,7 +2624,7 @@ LV2PluginInfo::load(Session& session) } std::vector -LV2PluginInfo::get_presets(Session&) +LV2PluginInfo::get_presets (bool /*user_only*/) const { std::vector p; #ifndef NO_PLUGIN_STATE diff --git a/libs/ardour/lxvst_plugin.cc b/libs/ardour/lxvst_plugin.cc index ac868cd565..2c50144f26 100644 --- a/libs/ardour/lxvst_plugin.cc +++ b/libs/ardour/lxvst_plugin.cc @@ -99,7 +99,7 @@ LXVSTPluginInfo::load (Session& session) } std::vector -LXVSTPluginInfo::get_presets(Session&) +LXVSTPluginInfo::get_presets (bool user_only) const { std::vector p; #ifndef NO_PLUGIN_STATE @@ -107,45 +107,47 @@ LXVSTPluginInfo::get_presets(Session&) return p; } -#if 0 // TODO - cache, instantiating the plugin can be heavy - /* Built-in presets */ - VSTHandle* handle = vstfx_load(path.c_str()); - Session::vst_current_loading_id = atoi (unique_id); - AEffect* plugin = handle->main_entry (Session::vst_callback); - Session::vst_current_loading_id = 0; - - plugin->dispatcher (plugin, effOpen, 0, 0, 0, 0); // :( - int const vst_version = plugin->dispatcher (plugin, effGetVstVersion, 0, 0, NULL, 0); - - for (int i = 0; i < plugin->numPrograms; ++i) { - Plugin::PresetRecord r (string_compose (X_("VST:%1:%2"), unique_id, i), "", false); - if (vst_version >= 2) { - char buf[256]; - if (plugin->dispatcher (plugin, 29, i, 0, buf, 0) == 1) { - r.label = buf; + if (!user_only) { + // TODO - cache, instantiating the plugin can be heavy + /* Built-in presets */ + VSTHandle* handle = vstfx_load(path.c_str()); + Session::vst_current_loading_id = atoi (unique_id); + AEffect* plugin = handle->main_entry (Session::vst_callback); + Session::vst_current_loading_id = 0; + + plugin->dispatcher (plugin, effOpen, 0, 0, 0, 0); // :( + int const vst_version = plugin->dispatcher (plugin, effGetVstVersion, 0, 0, NULL, 0); + + for (int i = 0; i < plugin->numPrograms; ++i) { + Plugin::PresetRecord r (string_compose (X_("VST:%1:%2"), unique_id, i), "", false); + if (vst_version >= 2) { + char buf[256]; + if (plugin->dispatcher (plugin, 29, i, 0, buf, 0) == 1) { + r.label = buf; + } else { + r.label = string_compose (_("Preset %1"), i); + } } else { r.label = string_compose (_("Preset %1"), i); } - } else { - r.label = string_compose (_("Preset %1"), i); + p.push_back (r); } - p.push_back (r); - } - plugin->dispatcher (plugin, effMainsChanged, 0, 0, 0, 0); - plugin->dispatcher (plugin, effClose, 0, 0, 0, 0); // :( + plugin->dispatcher (plugin, effMainsChanged, 0, 0, 0, 0); + plugin->dispatcher (plugin, effClose, 0, 0, 0, 0); // :( - if (handle->plugincnt) { - handle->plugincnt--; + if (handle->plugincnt) { + handle->plugincnt--; + } + vstfx_unload (handle); } - vstfx_unload (handle); -#endif + /* user presets */ XMLTree* t = new XMLTree; std::string pf = Glib::build_filename (ARDOUR::user_config_directory (), "presets", string_compose ("vst-%1", unique_id)); if (Glib::file_test (pf, Glib::FILE_TEST_EXISTS)) { t->set_filename (pf); - if (t->read ()) { + if (t->read ()) { // TODO read names only. skip parsing the actual data XMLNode* root = t->root (); for (XMLNodeList::const_iterator i = root->children().begin(); i != root->children().end(); ++i) { XMLProperty* uri = (*i)->property (X_("uri")); diff --git a/libs/ardour/windows_vst_plugin.cc b/libs/ardour/windows_vst_plugin.cc index 46097e7feb..a480642e3a 100644 --- a/libs/ardour/windows_vst_plugin.cc +++ b/libs/ardour/windows_vst_plugin.cc @@ -95,7 +95,7 @@ WindowsVSTPluginInfo::load (Session& session) } std::vector -WindowsVSTPluginInfo::get_presets(Session&) +WindowsVSTPluginInfo::get_presets (bool user_only) const { std::vector p; #ifndef NO_PLUGIN_STATE @@ -103,7 +103,9 @@ WindowsVSTPluginInfo::get_presets(Session&) return p; } - // TODO cache and load factory-preset names + if (!user_only) { + // TODO cache and load factory-preset names + } /* user presets */ XMLTree* t = new XMLTree;