X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fardour%2Fport_insert.cc;h=dee661db4157c5e05e7bd781aca1b16066b2a41b;hb=7d96960b162d25da87c388a3083775e8770bba56;hp=25234dbf77b34548a02a83f092c00d4add79e082;hpb=05184ed52ffcdcad3c071d4c99287f832f42b74b;p=ardour.git diff --git a/libs/ardour/port_insert.cc b/libs/ardour/port_insert.cc index 25234dbf77..dee661db41 100644 --- a/libs/ardour/port_insert.cc +++ b/libs/ardour/port_insert.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2000,2007 Paul Davis + Copyright (C) 2000,2007 Paul Davis This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -19,20 +19,20 @@ #include -#include -#include -#include +#include "pbd/failed_constructor.h" +#include "pbd/xml++.h" -#include -#include -#include -#include -#include +#include "ardour/delivery.h" +#include "ardour/port_insert.h" +#include "ardour/plugin.h" +#include "ardour/port.h" +#include "ardour/route.h" +#include "ardour/buffer_set.h" -#include -#include -#include +#include "ardour/audioengine.h" +#include "ardour/session.h" +#include "ardour/types.h" #include "i18n.h" @@ -40,65 +40,47 @@ using namespace std; using namespace ARDOUR; using namespace PBD; -PortInsert::PortInsert (Session& s, Placement p) - : Insert (s, string_compose (_("insert %1"), (bitslot = s.next_insert_id()) + 1), p, 1, -1, 1, -1) +PortInsert::PortInsert (Session& s, boost::shared_ptr mm) + : IOProcessor (s, true, true, string_compose (_("insert %1"), (bitslot = s.next_insert_id()) + 1), "") + , _out (new Delivery (s, _output, mm, _name, Delivery::Insert)) { - init (); - RedirectCreated (this); /* EMIT SIGNAL */ + ProcessorCreated (this); /* EMIT SIGNAL */ } -PortInsert::PortInsert (const PortInsert& other) - : Insert (other._session, string_compose (_("insert %1"), (bitslot = other._session.next_insert_id()) + 1), other.placement(), 1, -1, 1, -1) -{ - init (); - RedirectCreated (this); /* EMIT SIGNAL */ -} - -void -PortInsert::init () -{ - if (add_input_port ("", this)) { - error << _("PortInsert: cannot add input port") << endmsg; - throw failed_constructor(); - } - - if (add_output_port ("", this)) { - error << _("PortInsert: cannot add output port") << endmsg; - throw failed_constructor(); - } -} +PortInsert::PortInsert (Session& s, boost::shared_ptr mm, const XMLNode& node) + : IOProcessor (s, true, true, "unnamed port insert") + , _out (new Delivery (s, _output, mm, _name, Delivery::Insert)) -PortInsert::PortInsert (Session& s, const XMLNode& node) - : Insert (s, "will change", PreFader) { - if (set_state (node)) { + if (set_state (node, Stateful::loading_state_version)) { throw failed_constructor(); } - RedirectCreated (this); /* EMIT SIGNAL */ + ProcessorCreated (this); /* EMIT SIGNAL */ } PortInsert::~PortInsert () { - GoingAway (); } void -PortInsert::run (BufferSet& bufs, nframes_t start_frame, nframes_t end_frame, nframes_t nframes, nframes_t offset) +PortInsert::run (BufferSet& bufs, sframes_t start_frame, sframes_t end_frame, nframes_t nframes, bool) { - if (n_outputs().get(_default_type) == 0) { + if (_output->n_ports().n_total() == 0) { return; } - if (!active()) { + if (!_active && !_pending_active) { /* deliver silence */ - silence (nframes, offset); - return; + silence (nframes); + goto out; } - deliver_output(bufs, start_frame, end_frame, nframes, offset); + _out->run (bufs, start_frame, end_frame, nframes, true); + _input->collect_input (bufs, nframes, ChanCount::ZERO); - collect_input(bufs, nframes, offset); + out: + _active = _pending_active; } XMLNode& @@ -110,18 +92,17 @@ PortInsert::get_state(void) XMLNode& PortInsert::state (bool full) { - XMLNode *node = new XMLNode("Insert"); + XMLNode& node = Processor::state(full); char buf[32]; - node->add_child_nocopy (Redirect::state(full)); - node->add_property ("type", "port"); + node.add_property ("type", "port"); snprintf (buf, sizeof (buf), "%" PRIu32, bitslot); - node->add_property ("bitslot", buf); + node.add_property ("bitslot", buf); - return *node; + return node; } int -PortInsert::set_state(const XMLNode& node) +PortInsert::set_state (const XMLNode& node, int version) { XMLNodeList nlist = node.children(); XMLNodeIterator niter; @@ -129,10 +110,10 @@ PortInsert::set_state(const XMLNode& node) const XMLProperty *prop; if ((prop = node.property ("type")) == 0) { - error << _("XML node describing insert is missing the `type' field") << endmsg; + error << _("XML node describing port insert is missing the `type' field") << endmsg; return -1; } - + if (prop->value() != "port") { error << _("non-port insert XML used for port plugin insert") << endmsg; return -1; @@ -145,23 +126,23 @@ PortInsert::set_state(const XMLNode& node) _session.mark_insert_id (bitslot); } + const XMLNode* insert_node = &node; + + // legacy sessions: search for child IOProcessor node for (niter = nlist.begin(); niter != nlist.end(); ++niter) { - if ((*niter)->name() == Redirect::state_node_name) { - Redirect::set_state (**niter); + if ((*niter)->name() == "IOProcessor") { + insert_node = *niter; break; } } - if (niter == nlist.end()) { - error << _("XML node describing insert is missing a Redirect node") << endmsg; - return -1; - } + Processor::set_state (*insert_node, version); return 0; } -ARDOUR::nframes_t -PortInsert::latency() +ARDOUR::nframes_t +PortInsert::signal_latency() const { /* because we deliver and collect within the same cycle, all I/O is necessarily delayed by at least frames_per_cycle(). @@ -170,73 +151,54 @@ PortInsert::latency() need to take that into account too. */ - return _session.engine().frames_per_cycle() + input_latency(); + return _session.engine().frames_per_cycle() + _input->signal_latency(); } bool -PortInsert::can_support_input_configuration (ChanCount in) const +PortInsert::configure_io (ChanCount in, ChanCount out) { - if (input_maximum() == ChanCount::INFINITE && output_maximum() == ChanCount::INFINITE) { - - /* not configured yet */ - - return true; /* we can support anything the first time we're asked */ + /* for an insert, processor input corresponds to IO output, and vice versa */ - } else { - - /* the "input" config for a port insert corresponds to how - many output ports it will have. - */ - - if (output_maximum() == in) { + if (_input->ensure_io (in, false, this) != 0) { + return false; + } - return true; - } + if (_output->ensure_io (out, false, this) != 0) { + return false; } - return false; + return Processor::configure_io (in, out); } -ChanCount -PortInsert::output_for_input_configuration (ChanCount in) const +bool +PortInsert::can_support_io_configuration (const ChanCount& in, ChanCount& out) const { - return in; + out = in; + return true; } bool -PortInsert::configure_io (ChanCount in, ChanCount out) +PortInsert::set_name (const std::string& name) { - /* do not allow configuration to be changed outside the range of - the last request config. or something like that. - */ - - - /* this is a bit odd: + bool ret = Processor::set_name (name); - the number of inputs we are required to handle corresponds - to the number of output ports we need. + ret = (ret && _input->set_name (name) && _output->set_name (name)); - the number of outputs we are required to have corresponds - to the number of input ports we need. - */ - - set_output_maximum (in); - set_output_minimum (in); - set_input_maximum (out); - set_input_minimum (out); - - return (ensure_io (out, in, false, this) == 0); + return ret; } -ChanCount -PortInsert::output_streams() const +void +PortInsert::activate () { - return n_inputs (); + IOProcessor::activate (); + + _out->activate (); } -ChanCount -PortInsert::input_streams() const +void +PortInsert::deactivate () { - return n_outputs (); -} + IOProcessor::deactivate (); + _out->deactivate (); +}