From f44e2e55fdd6e4d265f3eff715b071a27da8b5eb Mon Sep 17 00:00:00 2001 From: Ben Loftis Date: Tue, 21 Apr 2015 08:18:10 -0500 Subject: merge monitor_section branch --- libs/ardour/ardour/session.h | 1 + libs/ardour/route.cc | 5 ++ libs/ardour/session.cc | 115 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 121 insertions(+) (limited to 'libs') diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index 75b3bd2006..30afd00fdb 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -702,6 +702,7 @@ class LIBARDOUR_API Session : public PBD::StatefulDestructible, public PBD::Scop /* monitor/master out */ void add_monitor_section (); + void reset_monitor_section (); void remove_monitor_section (); boost::shared_ptr monitor_out() const { return _monitor_out; } diff --git a/libs/ardour/route.cc b/libs/ardour/route.cc index 36adbfa148..e22acd8d4d 100644 --- a/libs/ardour/route.cc +++ b/libs/ardour/route.cc @@ -3096,6 +3096,11 @@ Route::output_change_handler (IOChange change, void * /*src*/) */ need_to_queue_solo_change = false; configure_processors (0); + + if (is_master()) { + _session.reset_monitor_section(); + } + io_changed (); /* EMIT SIGNAL */ } diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index a45175cef3..31f2635ac3 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -1060,6 +1060,121 @@ Session::add_monitor_section () } } +void +Session::reset_monitor_section () +{ + /* Process lock should be held by the caller.*/ + + if (!_monitor_out) { + return; + } + + uint32_t limit = _master_out->n_outputs().n_audio(); + + /* connect the inputs to the master bus outputs. this + * represents a separate data feed from the internal sends from + * each route. as of jan 2011, it allows the monitor section to + * conditionally ignore either the internal sends or the normal + * input feed, but we should really find a better way to do + * this, i think. + */ + + _master_out->output()->disconnect (this); + _monitor_out->output()->disconnect (this); + + _monitor_out->input()->ensure_io (_master_out->output()->n_ports(), false, this); + _monitor_out->output()->ensure_io (_master_out->output()->n_ports(), false, this); + + for (uint32_t n = 0; n < limit; ++n) { + boost::shared_ptr p = _monitor_out->input()->ports().nth_audio_port (n); + boost::shared_ptr o = _master_out->output()->ports().nth_audio_port (n); + + if (o) { + string connect_to = o->name(); + if (_monitor_out->input()->connect (p, connect_to, this)) { + error << string_compose (_("cannot connect control input %1 to %2"), n, connect_to) + << endmsg; + break; + } + } + } + + /* connect monitor section to physical outs + */ + + if (Config->get_auto_connect_standard_busses()) { + + if (!Config->get_monitor_bus_preferred_bundle().empty()) { + + boost::shared_ptr b = bundle_by_name (Config->get_monitor_bus_preferred_bundle()); + + if (b) { + _monitor_out->output()->connect_ports_to_bundle (b, true, this); + } else { + warning << string_compose (_("The preferred I/O for the monitor bus (%1) cannot be found"), + Config->get_monitor_bus_preferred_bundle()) + << endmsg; + } + + } else { + + /* Monitor bus is audio only */ + + vector outputs[DataType::num_types]; + + for (uint32_t i = 0; i < DataType::num_types; ++i) { + _engine.get_physical_outputs (DataType (DataType::Symbol (i)), outputs[i]); + } + + uint32_t mod = outputs[DataType::AUDIO].size(); + uint32_t limit = _monitor_out->n_outputs().get (DataType::AUDIO); + + if (mod != 0) { + + for (uint32_t n = 0; n < limit; ++n) { + + boost::shared_ptr p = _monitor_out->output()->ports().port(DataType::AUDIO, n); + string connect_to; + if (outputs[DataType::AUDIO].size() > (n % mod)) { + connect_to = outputs[DataType::AUDIO][n % mod]; + } + + if (!connect_to.empty()) { + if (_monitor_out->output()->connect (p, connect_to, this)) { + error << string_compose ( + _("cannot connect control output %1 to %2"), + n, connect_to) + << endmsg; + break; + } + } + } + } + } + } + + /* Connect tracks to monitor section. Note that in an + existing session, the internal sends will already exist, but we want the + routes to notice that they connect to the control out specifically. + */ + + + boost::shared_ptr rls = routes.reader (); + + PBD::Unwinder uw (ignore_route_processor_changes, true); + + for (RouteList::iterator x = rls->begin(); x != rls->end(); ++x) { + + if ((*x)->is_monitor()) { + /* relax */ + } else if ((*x)->is_master()) { + /* relax */ + } else { + (*x)->enable_monitor_send (); + } + } +} + void Session::hookup_io () { -- cgit v1.2.3