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
This commit is contained in:
parent
3710a977fc
commit
e6e7377cd8
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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
|
||||
|
@ -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.
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
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);
|
||||
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;
|
||||
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); // :(
|
||||
|
||||
if (handle->plugincnt) {
|
||||
handle->plugincnt--;
|
||||
}
|
||||
vstfx_unload (handle);
|
||||
}
|
||||
|
||||
plugin->dispatcher (plugin, effMainsChanged, 0, 0, 0, 0);
|
||||
plugin->dispatcher (plugin, effClose, 0, 0, 0, 0); // :(
|
||||
|
||||
if (handle->plugincnt) {
|
||||
handle->plugincnt--;
|
||||
}
|
||||
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"));
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user