X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fardour%2Finternal_send.cc;h=210835d17607f427c89326d902352160203e7ae2;hb=c937a67f6ee7e9f280a097683528201489ae6930;hp=f44c0617db7bc68a388a836b7f29ab1b4df34138;hpb=94cdb91ec6957cc498c850f911b58b8e5d66d54e;p=ardour.git diff --git a/libs/ardour/internal_send.cc b/libs/ardour/internal_send.cc index f44c0617db..210835d176 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,48 +30,62 @@ 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) +InternalSend::InternalSend (Session& s, boost::shared_ptr p, boost::shared_ptr mm, boost::shared_ptr sendto, Delivery::Role role) + : Send (s, p, mm, role) { - if ((target = _send_to->get_return_buffer ()) == 0) { - throw failed_constructor(); - } + if (sendto) { + if (use_target (sendto)) { + throw failed_constructor(); + } + } - set_name (sendto->name()); - - _send_to->GoingAway.connect (mem_fun (*this, &InternalSend::send_to_going_away)); + _amp->set_gain (0, 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() */) +InternalSend::~InternalSend () { - /* 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 (_send_to) { + _send_to->remove_send_from_internal_return (this); + } } -InternalSend::~InternalSend () +int +InternalSend::use_target (boost::shared_ptr sendto) { if (_send_to) { - _send_to->release_return_buffer (); + _send_to->remove_send_from_internal_return (this); } + + _send_to = sendto; - connect_c.disconnect (); + _send_to->add_send_to_internal_return (this); + + 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) +InternalSend::run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame, pframes_t nframes, bool) { - if ((!_active && !_pending_active) || !target || !_send_to) { + if ((!_active && !_pending_active) || !_send_to) { _meter->reset (); return; } @@ -94,7 +106,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. @@ -114,7 +126,7 @@ InternalSend::run (BufferSet& bufs, sframes_t start_frame, sframes_t end_frame, // so that we don't overwrite the main automation data for the route amp // _amp->setup_gain_automation (start_frame, end_frame, nframes); - _amp->run (mixbufs, start_frame, end_frame, nframes); + _amp->run (mixbufs, start_frame, end_frame, nframes, true); /* XXX NEED TO PAN */ @@ -124,22 +136,21 @@ InternalSend::run (BufferSet& bufs, sframes_t start_frame, sframes_t end_frame, if (_amp->gain_control()->get_value() == 0) { _meter->reset(); } else { - _meter->run (mixbufs, start_frame, end_frame, nframes); + _meter->run (mixbufs, start_frame, end_frame, nframes, true); } } - /* deliver to target */ - - target->merge_from (mixbufs, nframes); + /* target will pick up our output when it is ready */ out: _active = _pending_active; } -void -InternalSend::set_block_size (nframes_t nframes) +int +InternalSend::set_block_size (pframes_t nframes) { mixbufs.ensure_buffers (_configured_input, nframes); + return 0; } bool @@ -171,7 +182,7 @@ InternalSend::get_state() } int -InternalSend::set_our_state (const XMLNode& node, int version) +InternalSend::set_our_state (const XMLNode& node, int /*version*/) { const XMLProperty* prop; @@ -185,7 +196,7 @@ InternalSend::set_our_state (const XMLNode& node, int version) */ if (!IO::connecting_legal) { - connect_c = IO::ConnectingLegal.connect (mem_fun (*this, &InternalSend::connect_when_legal)); + IO::ConnectingLegal.connect_same_thread (connect_c, boost::bind (&InternalSend::connect_when_legal, this)); } else { connect_when_legal (); } @@ -211,17 +222,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 @@ -240,13 +248,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) { @@ -265,3 +273,11 @@ InternalSend::visible () const return false; } + +void +InternalSend::send_to_property_changed (const PropertyChange& what_changed) +{ + if (what_changed.contains (Properties::name)) { + set_name (_send_to->name ()); + } +}