diff options
author | Robin Gareus <robin@gareus.org> | 2015-12-25 22:38:48 +0100 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2015-12-25 22:38:48 +0100 |
commit | 81a3ae985d3059e26d5af2e933a7eca0ecdd29fd (patch) | |
tree | 87413e20aa42b61197930cad513badb79975d144 /libs/ardour/plugin.cc | |
parent | e6cb65a171e9455a94fb9e43409c9d178759d431 (diff) |
Keep plugin presets in sync across plugin-instances.
Diffstat (limited to 'libs/ardour/plugin.cc')
-rw-r--r-- | libs/ardour/plugin.cc | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/libs/ardour/plugin.cc b/libs/ardour/plugin.cc index d03024b64b..d6c9a48805 100644 --- a/libs/ardour/plugin.cc +++ b/libs/ardour/plugin.cc @@ -78,6 +78,8 @@ static bool seen_get_state_message = false; static bool seen_set_state_message = false; #endif +PBD::Signal2<void, std::string, Plugin*> Plugin::PresetsChanged; + bool PluginInfo::is_instrument () const { @@ -93,6 +95,7 @@ Plugin::Plugin (AudioEngine& e, Session& s) , _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) @@ -107,6 +110,7 @@ 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 () @@ -122,6 +126,7 @@ Plugin::remove_preset (string name) _last_preset.uri = ""; _parameter_changed_since_last_preset = false; PresetRemoved (); /* EMIT SIGNAL */ + PresetsChanged (unique_id(), this); /* EMIT SIGNAL */ } /** @return PresetRecord with empty URI on failure */ @@ -133,6 +138,7 @@ Plugin::save_preset (string name) if (!uri.empty()) { _presets.insert (make_pair (uri, PresetRecord (uri, name))); PresetAdded (); /* EMIT SIGNAL */ + PresetsChanged (unique_id(), this); /* EMIT SIGNAL */ } return PresetRecord (uri, name); @@ -309,6 +315,17 @@ Plugin::resolve_midi () _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 () |