X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fardour%2Fsend.cc;h=929b1fc9a831b489ac95fd25a9597b2492ea5933;hb=82a7819518d9cac90ae9d6963a97544b9549c283;hp=c67e0fcdbeff619b2dbf99f76b09b98e5d41a3a5;hpb=0b572cdd84151335594965a3f0ed16f1665dfa56;p=ardour.git diff --git a/libs/ardour/send.cc b/libs/ardour/send.cc index c67e0fcdbe..929b1fc9a8 100644 --- a/libs/ardour/send.cc +++ b/libs/ardour/send.cc @@ -15,7 +15,6 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id$ */ #include @@ -34,15 +33,14 @@ using namespace ARDOUR; using namespace PBD; Send::Send (Session& s, Placement p) - : Redirect (s, s.next_send_name(), p) + : IOProcessor (s, string_compose (_("send %1"), (bitslot = s.next_send_id()) + 1), p) { _metering = false; - save_state (_("initial state")); - RedirectCreated (this); /* EMIT SIGNAL */ + ProcessorCreated (this); /* EMIT SIGNAL */ } Send::Send (Session& s, const XMLNode& node) - : Redirect (s, "send", PreFader) + : IOProcessor (s, "send", PreFader) { _metering = false; @@ -50,21 +48,19 @@ Send::Send (Session& s, const XMLNode& node) throw failed_constructor(); } - save_state (_("initial state")); - RedirectCreated (this); /* EMIT SIGNAL */ + ProcessorCreated (this); /* EMIT SIGNAL */ } Send::Send (const Send& other) - : Redirect (other._session, other._session.next_send_name(), other.placement()) + : IOProcessor (other._session, string_compose (_("send %1"), (bitslot = other._session.next_send_id()) + 1), other.placement()) { _metering = false; - save_state (_("initial state")); - RedirectCreated (this); /* EMIT SIGNAL */ + ProcessorCreated (this); /* EMIT SIGNAL */ } Send::~Send () { - GoingAway (this); + GoingAway (); } XMLNode& @@ -76,9 +72,13 @@ Send::get_state(void) XMLNode& Send::state(bool full) { - XMLNode *node = new XMLNode("Send"); - node->add_child_nocopy (Redirect::state(full)); - return *node; + XMLNode& node = IOProcessor::state(full); + char buf[32]; + node.add_property ("type", "send"); + snprintf (buf, sizeof (buf), "%" PRIu32, bitslot); + node.add_property ("bitslot", buf); + + return node; } int @@ -86,51 +86,60 @@ Send::set_state(const XMLNode& node) { XMLNodeList nlist = node.children(); XMLNodeIterator niter; - - for (niter = nlist.begin(); niter != nlist.end(); ++niter) { - if ((*niter)->name() == Redirect::state_node_name) { - Redirect::set_state (**niter); - break; - } + const XMLProperty* prop; + + if ((prop = node.property ("bitslot")) == 0) { + bitslot = _session.next_send_id(); + } else { + sscanf (prop->value().c_str(), "%" PRIu32, &bitslot); + _session.mark_send_id (bitslot); } - if (niter == nlist.end()) { - error << _("XML node describing a send is missing a Redirect node") << endmsg; - return -1; + const XMLNode* insert_node = &node; + + /* Send has regular IO automation (gain, pan) */ + + for (niter = nlist.begin(); niter != nlist.end(); ++niter) { + if ((*niter)->name() == "IOProcessor") { + insert_node = *niter; + } else if ((*niter)->name() == X_("Automation")) { + _io->set_automation_state (*(*niter), Parameter(GainAutomation)); + } } + + IOProcessor::set_state (*insert_node); return 0; } void -Send::run (BufferSet& bufs, jack_nframes_t start_frame, jack_nframes_t end_frame, jack_nframes_t nframes, jack_nframes_t offset) +Send::run_in_place (BufferSet& bufs, nframes_t start_frame, nframes_t end_frame, nframes_t nframes, nframes_t offset) { if (active()) { // we have to copy the input, because IO::deliver_output may alter the buffers // in-place, which a send must never do. - BufferSet& sendbufs = _session.get_send_buffers(bufs.count()); + BufferSet& sendbufs = _session.get_mix_buffers(bufs.count()); sendbufs.read_from(bufs, nframes); assert(sendbufs.count() == bufs.count()); - assert(sendbufs.count() == _outputs.count()); - IO::deliver_output (sendbufs, start_frame, end_frame, nframes, offset); + _io->deliver_output (sendbufs, start_frame, end_frame, nframes, offset); if (_metering) { - if (_gain == 0) { - _meter->reset(); + if (_io->_gain == 0) { + _io->_meter->reset(); } else { - _meter->run(output_buffers(), nframes, offset); + _io->_meter->run(_io->output_buffers(), start_frame, end_frame, nframes, offset); } } } else { - silence (nframes, offset); + _io->silence (nframes, offset); if (_metering) { - _meter->reset(); + _io->_meter->reset(); } } } @@ -142,15 +151,72 @@ Send::set_metering (bool yn) if (!_metering) { /* XXX possible thread hazard here */ - peak_meter().reset(); + _io->peak_meter().reset(); } } -void -Send::expect_inputs (const ChanCount& expected) +bool +Send::can_support_input_configuration (ChanCount in) const { - if (expected != _expected_inputs) { - _expected_inputs = expected; - reset_panner (); + if (_io->input_maximum() == ChanCount::INFINITE && _io->output_maximum() == ChanCount::INFINITE) { + + /* not configured yet */ + + return true; /* we can support anything the first time we're asked */ + + } else { + + /* the "input" config for a port insert corresponds to how + many output ports it will have. + */ + + if (_io->output_maximum() == in) { + + return true; + } } + + return false; +} + +ChanCount +Send::output_for_input_configuration (ChanCount in) const +{ + // from the internal (Insert) perspective a Send does not modify its input whatsoever + return in; +} + +bool +Send::configure_io (ChanCount in, ChanCount out) +{ + /* we're transparent no matter what. fight the power. */ + if (out != in) + return false; + + _io->set_output_maximum (in); + _io->set_output_minimum (in); + _io->set_input_maximum (ChanCount::ZERO); + _io->set_input_minimum (ChanCount::ZERO); + + bool success = _io->ensure_io (ChanCount::ZERO, in, false, this) == 0; + + if (success) { + Processor::configure_io(in, out); + _io->reset_panner(); + return true; + } else { + return false; + } +} + +ChanCount +Send::output_streams() const +{ + return _io->n_outputs (); +} + +ChanCount +Send::input_streams() const +{ + return _io->n_outputs (); // (sic) }