13
0

Add interface to inform plugins about replicated instances

This allows for asking plugins to synchronize internal state
that isn't visible to the host between plugin instances.
This commit is contained in:
Robin Gareus 2020-10-05 16:47:26 +02:00
parent 0fac5c9c2c
commit a28b1f548e
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
3 changed files with 22 additions and 0 deletions

View File

@ -177,6 +177,9 @@ public:
void realtime_locate (bool);
void monitoring_changed ();
virtual void add_slave (boost::shared_ptr<Plugin>, bool realtime) {}
virtual void remove_slave (boost::shared_ptr<Plugin>) {}
struct UILayoutHint {
UILayoutHint () : x0 (-1), x1 (-1), y0 (-1), y1 (-1), knob (false) { }
int x0;

View File

@ -421,6 +421,7 @@ private:
boost::shared_ptr<Plugin> plugin_factory (boost::shared_ptr<Plugin>);
void add_plugin (boost::shared_ptr<Plugin>);
void plugin_removed (boost::weak_ptr<Plugin>);
void add_sidechain_from_xml (const XMLNode& node, int version);

View File

@ -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> 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> (plugin)));
}
}
void
PluginInsert::plugin_removed (boost::weak_ptr<Plugin> wp)
{
boost::shared_ptr<Plugin> plugin = wp.lock();
if (_plugins.size () == 0 || !plugin) {
return;
}
_plugins[0]->remove_slave (plugin);
}
void