From a0810ed608cfa50a9f20269cf830fc1afa22da76 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Sun, 22 May 2022 00:16:22 +0200 Subject: [PATCH] LV2: pass patch-set messages to replicated plugin instances This also fixes impulse analysis plugin display --- libs/ardour/ardour/lv2_plugin.h | 6 ++++++ libs/ardour/lv2_plugin.cc | 28 ++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/libs/ardour/ardour/lv2_plugin.h b/libs/ardour/ardour/lv2_plugin.h index ccbe187ff3..adb9bcc552 100644 --- a/libs/ardour/ardour/lv2_plugin.h +++ b/libs/ardour/ardour/lv2_plugin.h @@ -144,6 +144,9 @@ class LIBARDOUR_API LV2Plugin : public ARDOUR::Plugin, public ARDOUR::Workee bool has_editor () const; bool has_message_output () const; + void add_slave (boost::shared_ptr, bool); + void remove_slave (boost::shared_ptr); + bool write_from_ui(uint32_t index, uint32_t protocol, uint32_t size, @@ -299,6 +302,9 @@ class LIBARDOUR_API LV2Plugin : public ARDOUR::Plugin, public ARDOUR::Workee Glib::Threads::Mutex _work_mutex; + Glib::Threads::Mutex _slave_lock; + std::set> _slaves; + #ifdef LV2_EXTENDED static void queue_draw (LV2_Inline_Display_Handle); static void midnam_update (LV2_Midnam_Handle); diff --git a/libs/ardour/lv2_plugin.cc b/libs/ardour/lv2_plugin.cc index 56fe3c2e80..b10a4ed0ba 100644 --- a/libs/ardour/lv2_plugin.cc +++ b/libs/ardour/lv2_plugin.cc @@ -1698,6 +1698,26 @@ LV2Plugin::has_editor() const return _impl->ui != NULL; } +void +LV2Plugin::add_slave (boost::shared_ptr p, bool) +{ + boost::shared_ptr lv2 = boost::dynamic_pointer_cast (p); + if (lv2) { + Glib::Threads::Mutex::Lock lm (_slave_lock); + _slaves.insert (lv2); + } +} + +void +LV2Plugin::remove_slave (boost::shared_ptr p) +{ + boost::shared_ptr lv2 = boost::dynamic_pointer_cast (p); + if (lv2) { + Glib::Threads::Mutex::Lock lm (_slave_lock); + _slaves.erase (lv2); + } +} + bool LV2Plugin::has_message_output() const { @@ -1761,6 +1781,14 @@ LV2Plugin::write_from_ui(uint32_t index, error << string_compose (_("LV2<%1>: Error writing from UI to plugin"), name()) << endmsg; return false; } + + Glib::Threads::Mutex::Lock lm (_slave_lock, Glib::Threads::TRY_LOCK); + if (lm.locked()) { + for (auto const& i : _slaves) { + i->write_from_ui (index, protocol, size, body); + } + } + return true; }