diff options
author | Robin Gareus <robin@gareus.org> | 2016-04-17 14:01:09 +0200 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2016-04-17 14:01:09 +0200 |
commit | bb090c0012340b637508e0930376b3d5afba5f5c (patch) | |
tree | d641fb6e6945f51ad39f112a37d4838e5b6d30f0 /libs/ardour/send.cc | |
parent | 514765631b67080432faad5850528b720edab2b6 (diff) |
add self-removing Sends (remove on disconnect)
The idea is to dynamically add/remove sends for feeding a sidechain
and re-use all existing "External Send" infrastructure in particular
latency compensation.
Diffstat (limited to 'libs/ardour/send.cc')
-rw-r--r-- | libs/ardour/send.cc | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/libs/ardour/send.cc b/libs/ardour/send.cc index 23ae860f47..ebe8c46c8f 100644 --- a/libs/ardour/send.cc +++ b/libs/ardour/send.cc @@ -77,6 +77,7 @@ Send::Send (Session& s, boost::shared_ptr<Pannable> p, boost::shared_ptr<MuteMas , _metering (false) , _delay_in (0) , _delay_out (0) + , _remove_on_disconnect (false) { if (_role == Listen) { /* we don't need to do this but it keeps things looking clean @@ -99,6 +100,9 @@ Send::Send (Session& s, boost::shared_ptr<Pannable> p, boost::shared_ptr<MuteMas if (panner_shell()) { panner_shell()->Changed.connect_same_thread (*this, boost::bind (&Send::panshell_changed, this)); } + if (_output) { + _output->changed.connect_same_thread (*this, boost::bind (&Send::snd_output_changed, this, _1, _2)); + } } Send::~Send () @@ -221,6 +225,8 @@ Send::state (bool full) node.add_property ("bitslot", buf); } + node.add_property("selfdestruct", _remove_on_disconnect ? "yes" : "no"); + node.add_child_nocopy (_amp->state (full)); return node; @@ -268,6 +274,10 @@ Send::set_state (const XMLNode& node, int version) } } + if ((prop = node.property (X_("selfdestruct"))) != 0) { + _remove_on_disconnect = string_is_affirmative (prop->value()); + } + XMLNodeList nlist = node.children(); for (XMLNodeIterator i = nlist.begin(); i != nlist.end(); ++i) { if ((*i)->name() == X_("Processor")) { @@ -403,3 +413,14 @@ Send::value_as_string (boost::shared_ptr<AutomationControl> ac) const { return _amp->value_as_string (ac); } + +void +Send::snd_output_changed (IOChange change, void* /*src*/) +{ + if (change.type & IOChange::ConnectionsChanged) { + if (!_output->connected() && _remove_on_disconnect) { + _remove_on_disconnect = false; + SelfDestruct (); /* EMIT SIGNAL */ + } + } +} |