X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fardour%2Finternal_send.cc;h=8ec543030870a76c09a37892572e7ebe0af8519e;hb=ad547e53fc168410b22628a8cb125e8d4da4b293;hp=368eff2be40542af7128ca1208bcddec32cadb0f;hpb=f450df300c9c057141a4caf79ff6dbfbf58492d9;p=ardour.git diff --git a/libs/ardour/internal_send.cc b/libs/ardour/internal_send.cc index 368eff2be4..8ec5430308 100644 --- a/libs/ardour/internal_send.cc +++ b/libs/ardour/internal_send.cc @@ -17,8 +17,6 @@ */ -#include - #include "pbd/error.h" #include "pbd/failed_constructor.h" @@ -32,27 +30,17 @@ using namespace PBD; using namespace ARDOUR; +using namespace std; InternalSend::InternalSend (Session& s, boost::shared_ptr mm, boost::shared_ptr sendto, Delivery::Role role) : Send (s, mm, role) - , _send_to (sendto) -{ - if ((target = _send_to->get_return_buffer ()) == 0) { - throw failed_constructor(); - } - - set_name (sendto->name()); - - _send_to->GoingAway.connect_same_thread (*this, boost::bind (&InternalSend::send_to_going_away, this)); - _send_to->NameChanged.connect_same_thread (*this, boost::bind (&InternalSend::send_to_name_changed, this)); -} - -InternalSend::InternalSend (Session& s, boost::shared_ptr mm, const XMLNode& node) - : Send (s, mm, node, Stateful::loading_state_version, Delivery::Aux /* will be reset in set_state() */), - target (0) + , target (0) { - /* Send constructor will set its state, so here we just need to set up our own */ - set_our_state (node, Stateful::loading_state_version); + if (sendto) { + if (use_target (sendto)) { + throw failed_constructor(); + } + } } InternalSend::~InternalSend () @@ -60,20 +48,40 @@ InternalSend::~InternalSend () if (_send_to) { _send_to->release_return_buffer (); } +} - connect_c.disconnect (); +int +InternalSend::use_target (boost::shared_ptr sendto) +{ + _send_to = sendto; + + if ((target = _send_to->get_return_buffer ()) == 0) { + return -1; + } + + set_name (sendto->name()); + _send_to_id = _send_to->id(); + + target_connections.drop_connections (); + + _send_to->DropReferences.connect_same_thread (target_connections, boost::bind (&InternalSend::send_to_going_away, this)); + _send_to->PropertyChanged.connect_same_thread (target_connections, boost::bind (&InternalSend::send_to_property_changed, this, _1));; + + return 0; } + void InternalSend::send_to_going_away () { target = 0; + target_connections.drop_connections (); _send_to.reset (); _send_to_id = "0"; } void -InternalSend::run (BufferSet& bufs, sframes_t start_frame, sframes_t end_frame, nframes_t nframes, bool) +InternalSend::run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame, nframes_t nframes, bool) { if ((!_active && !_pending_active) || !target || !_send_to) { _meter->reset (); @@ -96,7 +104,7 @@ InternalSend::run (BufferSet& bufs, sframes_t start_frame, sframes_t end_frame, Amp::apply_gain (mixbufs, nframes, _current_gain, tgain); _current_gain = tgain; - + } else if (tgain == 0.0) { /* we were quiet last time, and we're still supposed to be quiet. @@ -138,10 +146,16 @@ InternalSend::run (BufferSet& bufs, sframes_t start_frame, sframes_t end_frame, _active = _pending_active; } -void +int InternalSend::set_block_size (nframes_t nframes) { mixbufs.ensure_buffers (_configured_input, nframes); + + /* ensure that our target can cope with us merging this many frames to it */ + if (target) { + target->ensure_buffers (_configured_input, nframes); + } + return 0; } bool @@ -213,17 +227,14 @@ InternalSend::connect_when_legal () return 0; } - if ((_send_to = _session.route_by_id (_send_to_id)) == 0) { - error << X_("cannot find route to connect to") << endmsg; - return -1; - } + boost::shared_ptr sendto; - if ((target = _send_to->get_return_buffer ()) == 0) { - error << X_("target for internal send has no return buffer") << endmsg; + if ((sendto = _session.route_by_id (_send_to_id)) == 0) { + error << X_("cannot find route to connect to") << endmsg; return -1; } - return 0; + return use_target (sendto); } bool @@ -242,13 +253,13 @@ InternalSend::configure_io (ChanCount in, ChanCount out) } bool -InternalSend::set_name (const std::string& str) +InternalSend::set_name (const string& str) { /* rules for external sends don't apply to us */ return IOProcessor::set_name (str); } -std::string +string InternalSend::display_name () const { if (_role == Aux) { @@ -269,7 +280,9 @@ InternalSend::visible () const } void -InternalSend::send_to_name_changed () +InternalSend::send_to_property_changed (const PropertyChange& what_changed) { - set_name (_send_to->name ()); + if (what_changed.contains (Properties::name)) { + set_name (_send_to->name ()); + } }