summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2016-01-09 15:22:16 +0100
committerRobin Gareus <robin@gareus.org>2016-01-09 15:22:16 +0100
commite6e7377cd8596f8ed8b5d39634e550a05995999b (patch)
tree88351b0e9b0325e446805be31156899d48985a2e
parent3710a977fc396bfd279634b7fd7329a5eeeda028 (diff)
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
-rw-r--r--libs/ardour/ardour/audio_unit.h2
-rw-r--r--libs/ardour/ardour/ladspa_plugin.h2
-rw-r--r--libs/ardour/ardour/lv2_plugin.h2
-rw-r--r--libs/ardour/ardour/lxvst_plugin.h2
-rw-r--r--libs/ardour/ardour/plugin.h2
-rw-r--r--libs/ardour/ardour/windows_vst_plugin.h2
-rw-r--r--libs/ardour/audio_unit.cc8
-rw-r--r--libs/ardour/ladspa_plugin.cc2
-rw-r--r--libs/ardour/lv2_plugin.cc2
-rw-r--r--libs/ardour/lxvst_plugin.cc58
-rw-r--r--libs/ardour/windows_vst_plugin.cc6
11 files changed, 47 insertions, 41 deletions
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<Plugin::PresetRecord> get_presets(Session& session);
+ std::vector<Plugin::PresetRecord> 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<Plugin::PresetRecord> get_presets(Session& session);
+ std::vector<Plugin::PresetRecord> get_presets (bool user_only) const;
};
typedef boost::shared_ptr<LadspaPluginInfo> 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<Plugin::PresetRecord> get_presets(Session& session);
+ std::vector<Plugin::PresetRecord> 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<Plugin::PresetRecord> get_presets(Session&);
+ std::vector<Plugin::PresetRecord> 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<Plugin::PresetRecord> get_presets(Session& session) = 0;
+ virtual std::vector<Plugin::PresetRecord> 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<Plugin::PresetRecord> get_presets(Session&);
+ std::vector<Plugin::PresetRecord> 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<Plugin::PresetRecord>
-AUPluginInfo::get_presets(Session& session)
+AUPluginInfo::get_presets (bool user_only) const
{
std::vector<Plugin::PresetRecord> p;
boost::shared_ptr<CAComponent> 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<Plugin::PresetRecord>
-LadspaPluginInfo::get_presets(Session& session)
+LadspaPluginInfo::get_presets (bool /*user_only*/) const
{
std::vector<Plugin::PresetRecord> 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<Plugin::PresetRecord>
-LV2PluginInfo::get_presets(Session&)
+LV2PluginInfo::get_presets (bool /*user_only*/) const
{
std::vector<Plugin::PresetRecord> 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<Plugin::PresetRecord>
-LXVSTPluginInfo::get_presets(Session&)
+LXVSTPluginInfo::get_presets (bool user_only) const
{
std::vector<Plugin::PresetRecord> 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<Plugin::PresetRecord>
-WindowsVSTPluginInfo::get_presets(Session&)
+WindowsVSTPluginInfo::get_presets (bool user_only) const
{
std::vector<Plugin::PresetRecord> 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;