X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fardour%2Fio.cc;h=43a61061d9765b595c3e1eaf77d02134ca5dcb10;hb=b35f3088942ff623e9d09fe6acb1f214dddf73ce;hp=1b130097e7a0189a4ce69bcf17a7f7969353d1ee;hpb=ee42a6dd97045253d1a9bb32fc2e571d235f9967;p=ardour.git diff --git a/libs/ardour/io.cc b/libs/ardour/io.cc index 1b130097e7..43a61061d9 100644 --- a/libs/ardour/io.cc +++ b/libs/ardour/io.cc @@ -102,13 +102,12 @@ static double direct_gain_to_control (gain_t gain) { */ IO::IO (Session& s, const string& name, int input_min, int input_max, int output_min, int output_max, - DataType default_type, bool public_ports) + DataType default_type) : SessionObject(s, name), AutomatableControls (s), _output_buffers (new BufferSet()), _active(true), _default_type (default_type), - _public_ports (public_ports), _input_minimum (ChanCount::ZERO), _input_maximum (ChanCount::INFINITE), _output_minimum (ChanCount::ZERO), @@ -166,7 +165,6 @@ IO::IO (Session& s, const XMLNode& node, DataType dt) _default_type (dt) { _meter = new PeakMeter (_session); - _public_ports = true; // XXX get this from node _panner = 0; deferred_state = 0; no_panner_reset = false; @@ -425,7 +423,7 @@ IO::disconnect_input (Port* our_port, string other_port, void* src) /* disconnect it from the source */ - if (_session.engine().disconnect (other_port, our_port->name())) { + if (our_port->disconnect (other_port)) { error << string_compose(_("IO: cannot disconnect input port %1 from %2"), our_port->name(), other_port) << endmsg; return -1; } @@ -461,7 +459,7 @@ IO::connect_input (Port* our_port, string other_port, void* src) /* connect it to the source */ - if (_session.engine().connect (other_port, our_port->name())) { + if (our_port->connect (other_port)) { return -1; } } @@ -493,7 +491,7 @@ IO::disconnect_output (Port* our_port, string other_port, void* src) /* disconnect it from the destination */ - if (_session.engine().disconnect (our_port->name(), other_port)) { + if (our_port->disconnect (other_port)) { error << string_compose(_("IO: cannot disconnect output port %1 from %2"), our_port->name(), other_port) << endmsg; return -1; } @@ -529,7 +527,7 @@ IO::connect_output (Port* our_port, string other_port, void* src) /* connect it to the destination */ - if (_session.engine().connect (our_port->name(), other_port)) { + if (our_port->connect (other_port)) { return -1; } } @@ -644,7 +642,7 @@ IO::add_output_port (string destination, void* src, DataType type) string portname = build_legal_port_name (type, false); - if ((our_port = _session.engine().register_output_port (type, portname, _public_ports)) == 0) { + if ((our_port = _session.engine().register_output_port (type, portname)) == 0) { error << string_compose(_("IO: cannot register output port %1"), portname) << endmsg; return -1; } @@ -658,7 +656,7 @@ IO::add_output_port (string destination, void* src, DataType type) } if (destination.length()) { - if (_session.engine().connect (our_port->name(), destination)) { + if (our_port->connect (destination)) { return -1; } } @@ -748,7 +746,7 @@ IO::add_input_port (string source, void* src, DataType type) string portname = build_legal_port_name (type, true); - if ((our_port = _session.engine().register_input_port (type, portname, _public_ports)) == 0) { + if ((our_port = _session.engine().register_input_port (type, portname)) == 0) { error << string_compose(_("IO: cannot register input port %1"), portname) << endmsg; return -1; } @@ -763,7 +761,7 @@ IO::add_input_port (string source, void* src, DataType type) if (source.length()) { - if (_session.engine().connect (source, our_port->name())) { + if (our_port->connect (source)) { return -1; } } @@ -786,7 +784,7 @@ IO::disconnect_inputs (void* src) Glib::Mutex::Lock lm (io_lock); for (PortSet::iterator i = _inputs.begin(); i != _inputs.end(); ++i) { - _session.engine().disconnect (*i); + i->disconnect_all (); } check_bundles_connected_to_inputs (); @@ -808,7 +806,7 @@ IO::disconnect_outputs (void* src) Glib::Mutex::Lock lm (io_lock); for (PortSet::iterator i = _outputs.begin(); i != _outputs.end(); ++i) { - _session.engine().disconnect (*i); + i->disconnect_all (); } check_bundles_connected_to_outputs (); @@ -850,7 +848,7 @@ IO::ensure_inputs_locked (ChanCount count, bool clear, void* src) try { - if ((input_port = _session.engine().register_input_port (*t, portname, _public_ports)) == 0) { + if ((input_port = _session.engine().register_input_port (*t, portname)) == 0) { error << string_compose(_("IO: cannot register input port %1"), portname) << endmsg; return -1; } @@ -879,7 +877,7 @@ IO::ensure_inputs_locked (ChanCount count, bool clear, void* src) if (clear) { /* disconnect all existing ports so that we get a fresh start */ for (PortSet::iterator i = _inputs.begin(); i != _inputs.end(); ++i) { - _session.engine().disconnect (*i); + i->disconnect_all (); } } @@ -948,7 +946,7 @@ IO::ensure_io (ChanCount in, ChanCount out, bool clear, void* src) string portname = build_legal_port_name (*t, true); try { - if ((port = _session.engine().register_input_port (*t, portname, _public_ports)) == 0) { + if ((port = _session.engine().register_input_port (*t, portname)) == 0) { error << string_compose(_("IO: cannot register input port %1"), portname) << endmsg; return -1; } @@ -972,7 +970,7 @@ IO::ensure_io (ChanCount in, ChanCount out, bool clear, void* src) string portname = build_legal_port_name (*t, false); try { - if ((port = _session.engine().register_output_port (*t, portname, _public_ports)) == 0) { + if ((port = _session.engine().register_output_port (*t, portname)) == 0) { error << string_compose(_("IO: cannot register output port %1"), portname) << endmsg; return -1; } @@ -995,11 +993,11 @@ IO::ensure_io (ChanCount in, ChanCount out, bool clear, void* src) /* disconnect all existing ports so that we get a fresh start */ for (PortSet::iterator i = _inputs.begin(); i != _inputs.end(); ++i) { - _session.engine().disconnect (*i); + i->disconnect_all (); } for (PortSet::iterator i = _outputs.begin(); i != _outputs.end(); ++i) { - _session.engine().disconnect (*i); + i->disconnect_all (); } } @@ -1087,7 +1085,7 @@ IO::ensure_outputs_locked (ChanCount count, bool clear, void* src) string portname = build_legal_port_name (*t, false); - if ((output_port = _session.engine().register_output_port (*t, portname, _public_ports)) == 0) { + if ((output_port = _session.engine().register_output_port (*t, portname)) == 0) { error << string_compose(_("IO: cannot register output port %1"), portname) << endmsg; return -1; } @@ -1111,7 +1109,7 @@ IO::ensure_outputs_locked (ChanCount count, bool clear, void* src) if (clear) { /* disconnect all existing ports so that we get a fresh start */ for (PortSet::iterator i = _outputs.begin(); i != _outputs.end(); ++i) { - _session.engine().disconnect (*i); + i->disconnect_all (); } } @@ -1342,7 +1340,7 @@ IO::set_state (const XMLNode& node) if ((prop = node.property ("name")) != 0) { _name = prop->value(); /* used to set panner name with this, but no more */ - } + } if ((prop = node.property ("id")) != 0) { _id = prop->value (); @@ -2623,7 +2621,9 @@ IO::setup_bundle_for_inputs () } _bundle_for_inputs->suspend_signals (); - + + _bundle_for_inputs->set_type (default_type ()); + _bundle_for_inputs->remove_channels (); snprintf(buf, sizeof (buf), _("%s in"), _name.c_str()); @@ -2649,6 +2649,8 @@ IO::setup_bundle_for_outputs () _bundle_for_outputs->suspend_signals (); + _bundle_for_outputs->set_type (default_type ()); + _bundle_for_outputs->remove_channels (); snprintf(buf, sizeof (buf), _("%s out"), _name.c_str()); @@ -2674,23 +2676,22 @@ IO::bundles_connected_to_inputs () bundles.push_back (i->bundle); } - /* Normal bundles */ + /* Session bundles */ boost::shared_ptr b = _session.bundles (); for (ARDOUR::BundleList::iterator i = b->begin(); i != b->end(); ++i) { - if ((*i)->ports_are_outputs() == false || (*i)->nchannels() != n_inputs().n_total()) { - continue; + if ((*i)->connected_to (_bundle_for_inputs, _session.engine())) { + bundles.push_back (*i); } + } - for (uint32_t j = 0; j < n_inputs().n_total(); ++j) { - - Bundle::PortList const& pl = (*i)->channel_ports (j); - if (!pl.empty() && input(j)->connected_to (pl[0])) { - bundles.push_back (*i); - } - + /* Route bundles */ + boost::shared_ptr r = _session.get_routes (); + for (ARDOUR::RouteList::iterator i = r->begin(); i != r->end(); ++i) { + if ((*i)->bundle_for_outputs()->connected_to (_bundle_for_inputs, _session.engine())) { + bundles.push_back ((*i)->bundle_for_outputs()); } } - + return bundles; } @@ -2706,20 +2707,19 @@ IO::bundles_connected_to_outputs () bundles.push_back (i->bundle); } - /* Auto bundles */ + /* Session bundles */ boost::shared_ptr b = _session.bundles (); for (ARDOUR::BundleList::iterator i = b->begin(); i != b->end(); ++i) { - if ((*i)->ports_are_inputs() == false || (*i)->nchannels() != n_outputs().n_total()) { - continue; + if ((*i)->connected_to (_bundle_for_outputs, _session.engine())) { + bundles.push_back (*i); } + } - for (uint32_t j = 0; j < n_outputs().n_total(); ++j) { - - Bundle::PortList const& pl = (*i)->channel_ports (j); - - if (!pl.empty() && output(j)->connected_to (pl[0])) { - bundles.push_back (*i); - } + /* Route bundles */ + boost::shared_ptr r = _session.get_routes (); + for (ARDOUR::RouteList::iterator i = r->begin(); i != r->end(); ++i) { + if ((*i)->bundle_for_inputs()->connected_to (_bundle_for_outputs, _session.engine())) { + bundles.push_back ((*i)->bundle_for_inputs()); } }