diff --git a/libs/ardour/ardour/plugin.h b/libs/ardour/ardour/plugin.h index 3144302e43..8eecfacfa2 100644 --- a/libs/ardour/ardour/plugin.h +++ b/libs/ardour/ardour/plugin.h @@ -177,6 +177,9 @@ public: void realtime_locate (bool); void monitoring_changed (); + virtual void add_slave (boost::shared_ptr, bool realtime) {} + virtual void remove_slave (boost::shared_ptr) {} + struct UILayoutHint { UILayoutHint () : x0 (-1), x1 (-1), y0 (-1), y1 (-1), knob (false) { } int x0; diff --git a/libs/ardour/ardour/plugin_insert.h b/libs/ardour/ardour/plugin_insert.h index 569ed748a9..d1fa7e951e 100644 --- a/libs/ardour/ardour/plugin_insert.h +++ b/libs/ardour/ardour/plugin_insert.h @@ -421,6 +421,7 @@ private: boost::shared_ptr plugin_factory (boost::shared_ptr); void add_plugin (boost::shared_ptr); + void plugin_removed (boost::weak_ptr); void add_sidechain_from_xml (const XMLNode& node, int version); diff --git a/libs/ardour/plugin_insert.cc b/libs/ardour/plugin_insert.cc index 131892df5e..dc210a91a7 100644 --- a/libs/ardour/plugin_insert.cc +++ b/libs/ardour/plugin_insert.cc @@ -3151,6 +3151,9 @@ PluginInsert::get_impulse_analysis_plugin() ret->configure_io (internal_input_streams (), out); ret->set_owner (_owner); _impulseAnalysisPlugin = ret; + + _plugins[0]->add_slave (ret, false); + ret->DropReferences.connect_same_thread (*this, boost::bind (&PluginInsert::plugin_removed, this, _impulseAnalysisPlugin)); } else { ret = _impulseAnalysisPlugin.lock(); } @@ -3212,6 +3215,21 @@ PluginInsert::add_plugin (boost::shared_ptr plugin) #endif _plugins.push_back (plugin); + + if (_plugins.size() > 1) { + _plugins[0]->add_slave (plugin, true); + plugin->DropReferences.connect_same_thread (*this, boost::bind (&PluginInsert::plugin_removed, this, boost::weak_ptr (plugin))); + } +} + +void +PluginInsert::plugin_removed (boost::weak_ptr wp) +{ + boost::shared_ptr plugin = wp.lock(); + if (_plugins.size () == 0 || !plugin) { + return; + } + _plugins[0]->remove_slave (plugin); } void