, _parameter_changed_since_last_preset (false)
{
_pending_stop_events.ensure_buffers (DataType::MIDI, 1, 4096);
- PresetsChanged.connect_same_thread (_preset_connection, boost::bind (&Plugin::update_presets, this, _1 ,_2));
}
Plugin::Plugin (const Plugin& other)
, _parameter_changed_since_last_preset (false)
{
_pending_stop_events.ensure_buffers (DataType::MIDI, 1, 4096);
- PresetsChanged.connect_same_thread (_preset_connection, boost::bind (&Plugin::update_presets, this, _1 ,_2));
}
Plugin::~Plugin ()
Plugin::remove_preset (string name)
{
Plugin::PresetRecord const * p = preset_by_label (name);
+ if (!p) {
+ PBD::error << _("Trying to remove nonexistent preset.") << endmsg;
+ return;
+ }
if (!p->user) {
PBD::error << _("Cannot remove plugin factory preset.") << endmsg;
return;
}
do_remove_preset (name);
- _presets.erase (preset_by_label (name)->uri);
+ _presets.erase (p->uri);
_last_preset.uri = "";
_parameter_changed_since_last_preset = false;
- PresetRemoved (); /* EMIT SIGNAL */
+ _have_presets = false;
PresetsChanged (unique_id(), this); /* EMIT SIGNAL */
+ PresetRemoved (); /* EMIT SIGNAL */
}
/** @return PresetRecord with empty URI on failure */
if (!uri.empty()) {
_presets.insert (make_pair (uri, PresetRecord (uri, name)));
- PresetAdded (); /* EMIT SIGNAL */
+ _have_presets = false;
PresetsChanged (unique_id(), this); /* EMIT SIGNAL */
+ PresetAdded (); /* EMIT SIGNAL */
}
return PresetRecord (uri, name);
_have_pending_stop_events = true;
}
-void
-Plugin::update_presets (std::string src_unique_id, Plugin* src )
-{
- if (src == this || unique_id() != src_unique_id) {
- return;
- }
- _have_presets = false;
- // TODO check if a preset was added/removed and emit the proper signal
- // so far no subscriber distinguishes between PresetAdded and PresetRemoved
- PresetAdded();
-}
-
vector<Plugin::PresetRecord>
Plugin::get_presets ()
{
return false;
}
+#include "sha1.c"
+
string
VSTPlugin::do_save_preset (string name)
{
return "";
}
+ // prevent dups -- just in case
+ t->root()->remove_nodes_and_delete (X_("label"), name);
+
XMLNode* p = 0;
- /* XXX: use of _presets.size() + 1 for the unique ID here is dubious at best */
- string const uri = string_compose (X_("VST:%1:%2"), unique_id (), _presets.size() + 1);
+
+ char tmp[32];
+ snprintf (tmp, 31, "%d", _presets.size() + 1);
+ tmp[31] = 0;
+
+ char hash[41];
+ Sha1Digest s;
+ sha1_init (&s);
+ sha1_write (&s, (const uint8_t *) name.c_str(), name.size ());
+ sha1_write (&s, (const uint8_t *) tmp, strlen(tmp));
+ sha1_result_hash (&s, hash);
+
+ string const uri = string_compose (X_("VST:%1:x%2"), unique_id (), hash);
if (_plugin->flags & 32 /* effFlagsProgramsChunks */) {