From 54afc94e62b6397286d545744cea796f93f4b5f9 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Mon, 2 Feb 2009 22:17:06 +0000 Subject: Re-enable creation of stereo bundles for system IO, so that the mixer strip connection menus for stereo tracks are populated again. Also enable disconnection via these menus. git-svn-id: svn://localhost/ardour2/branches/3.0@4481 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/ardour/ardour/bundle.h | 15 ++++---- libs/ardour/ardour/io.h | 6 ++- libs/ardour/bundle.cc | 37 ++++++++++++++++++ libs/ardour/io.cc | 91 ++++++++++++++++++++++++++++----------------- libs/ardour/session.cc | 35 ++++++++++++++++- 5 files changed, 140 insertions(+), 44 deletions(-) (limited to 'libs') diff --git a/libs/ardour/ardour/bundle.h b/libs/ardour/ardour/bundle.h index 7e5cac6bf1..005e86842f 100644 --- a/libs/ardour/ardour/bundle.h +++ b/libs/ardour/ardour/bundle.h @@ -28,6 +28,8 @@ #include "ardour/data_type.h" namespace ARDOUR { + +class AudioEngine; /** A set of `channels', each of which is associated with 0 or more ports. * Each channel has a name which can be anything useful. @@ -96,7 +98,9 @@ class Bundle : public sigc::trackable bool offers_port_alone (std::string) const; void remove_channel (uint32_t); void remove_channels (); - void add_channels_from_bundle (boost::shared_ptr); + void add_channels_from_bundle (boost::shared_ptr); + void connect (boost::shared_ptr, AudioEngine &); + void disconnect (boost::shared_ptr, AudioEngine &); /** Set the name. * @param n New name. @@ -143,7 +147,7 @@ class Bundle : public sigc::trackable int parse_io_string (std::string const &, std::vector &); std::string _name; - ARDOUR::DataType _type; + DataType _type; bool _ports_are_inputs; }; @@ -153,7 +157,7 @@ struct BundleChannel { BundleChannel () : channel (0) {} - BundleChannel (boost::shared_ptr b, uint32_t c) + BundleChannel (boost::shared_ptr b, uint32_t c) : bundle (b), channel (c) {} bool operator== (BundleChannel const& other) const { @@ -164,13 +168,10 @@ struct BundleChannel return bundle != other.bundle || channel != other.channel; } - boost::shared_ptr bundle; + boost::shared_ptr bundle; uint32_t channel; }; - - - } #endif /* __ardour_bundle_h__ */ diff --git a/libs/ardour/ardour/io.h b/libs/ardour/ardour/io.h index 5a3c5c2b12..5bb7a3f3b7 100644 --- a/libs/ardour/ardour/io.h +++ b/libs/ardour/ardour/io.h @@ -128,8 +128,10 @@ class IO : public SessionObject, public AutomatableControls, public Latent int ensure_io (ChanCount in, ChanCount out, bool clear, void *src); - int connect_input_ports_to_bundle (boost::shared_ptr, void *src); - int connect_output_ports_to_bundle (boost::shared_ptr, void *src); + int connect_input_ports_to_bundle (boost::shared_ptr, void *); + int disconnect_input_ports_from_bundle (boost::shared_ptr, void *); + int connect_output_ports_to_bundle (boost::shared_ptr, void *); + int disconnect_output_ports_from_bundle (boost::shared_ptr, void *); BundleList bundles_connected_to_inputs (); BundleList bundles_connected_to_outputs (); diff --git a/libs/ardour/bundle.cc b/libs/ardour/bundle.cc index 48c0ead6e6..abf0bd07f9 100644 --- a/libs/ardour/bundle.cc +++ b/libs/ardour/bundle.cc @@ -22,6 +22,7 @@ #include #include #include +#include #include #include "i18n.h" @@ -243,3 +244,39 @@ Bundle::add_channels_from_bundle (boost::shared_ptr other) } } } + +void +Bundle::connect (boost::shared_ptr other, AudioEngine & engine) +{ + uint32_t const N = nchannels (); + assert (N == other->nchannels ()); + + for (uint32_t i = 0; i < N; ++i) { + Bundle::PortList const & our_ports = channel_ports (i); + Bundle::PortList const & other_ports = other->channel_ports (i); + + for (Bundle::PortList::const_iterator j = our_ports.begin(); j != our_ports.end(); ++j) { + for (Bundle::PortList::const_iterator k = other_ports.begin(); k != other_ports.end(); ++k) { + engine.connect (*j, *k); + } + } + } +} + +void +Bundle::disconnect (boost::shared_ptr other, AudioEngine & engine) +{ + uint32_t const N = nchannels (); + assert (N == other->nchannels ()); + + for (uint32_t i = 0; i < N; ++i) { + Bundle::PortList const & our_ports = channel_ports (i); + Bundle::PortList const & other_ports = other->channel_ports (i); + + for (Bundle::PortList::const_iterator j = our_ports.begin(); j != our_ports.end(); ++j) { + for (Bundle::PortList::const_iterator k = other_ports.begin(); k != other_ports.end(); ++k) { + engine.disconnect (*j, *k); + } + } + } +} diff --git a/libs/ardour/io.cc b/libs/ardour/io.cc index 89b3b9e89f..00281d510f 100644 --- a/libs/ardour/io.cc +++ b/libs/ardour/io.cc @@ -2062,25 +2062,7 @@ IO::connect_input_ports_to_bundle (boost::shared_ptr c, void* src) BLOCK_PROCESS_CALLBACK (); Glib::Mutex::Lock lm2 (io_lock); - /* Connect to the bundle, not worrying about any connections - that are already made. */ - - uint32_t cnt = c->nchannels (); - - for (uint32_t n = 0; n < cnt; ++n) { - const Bundle::PortList& pl = c->channel_ports (n); - - for (Bundle::PortList::const_iterator i = pl.begin(); i != pl.end(); ++i) { - - if (!_inputs.port(n)->connected_to (*i)) { - - if (_session.engine().connect (*i, _inputs.port(n)->name())) { - return -1; - } - } - - } - } + c->connect (_bundle_for_inputs, _session.engine()); /* If this is a UserBundle, make a note of what we've done */ @@ -2105,31 +2087,42 @@ IO::connect_input_ports_to_bundle (boost::shared_ptr c, void* src) } int -IO::connect_output_ports_to_bundle (boost::shared_ptr c, void* src) +IO::disconnect_input_ports_from_bundle (boost::shared_ptr c, void* src) { { BLOCK_PROCESS_CALLBACK (); Glib::Mutex::Lock lm2 (io_lock); - /* Connect to the bundle, not worrying about any connections - that are already made. */ - - uint32_t cnt = c->nchannels (); - - for (uint32_t n = 0; n < cnt; ++n) { + c->disconnect (_bundle_for_inputs, _session.engine()); + + /* If this is a UserBundle, make a note of what we've done */ - const Bundle::PortList& pl = c->channel_ports (n); + boost::shared_ptr ub = boost::dynamic_pointer_cast (c); + if (ub) { - for (Bundle::PortList::const_iterator i = pl.begin(); i != pl.end(); ++i) { + std::vector::iterator i = _bundles_connected_to_inputs.begin(); + while (i != _bundles_connected_to_inputs.end() && i->bundle != ub) { + ++i; + } - if (!_outputs.port(n)->connected_to (*i)) { - - if (_session.engine().connect (_outputs.port(n)->name(), *i)) { - return -1; - } - } + if (i != _bundles_connected_to_inputs.end()) { + _bundles_connected_to_inputs.erase (i); } } + } + + input_changed (IOChange (ConfigurationChanged|ConnectionsChanged), src); /* EMIT SIGNAL */ + return 0; +} + +int +IO::connect_output_ports_to_bundle (boost::shared_ptr c, void* src) +{ + { + BLOCK_PROCESS_CALLBACK (); + Glib::Mutex::Lock lm2 (io_lock); + + c->connect (_bundle_for_outputs, _session.engine()); /* If this is a UserBundle, make a note of what we've done */ @@ -2154,6 +2147,36 @@ IO::connect_output_ports_to_bundle (boost::shared_ptr c, void* src) return 0; } +int +IO::disconnect_output_ports_from_bundle (boost::shared_ptr c, void* src) +{ + { + BLOCK_PROCESS_CALLBACK (); + Glib::Mutex::Lock lm2 (io_lock); + + c->disconnect (_bundle_for_outputs, _session.engine()); + + /* If this is a UserBundle, make a note of what we've done */ + + boost::shared_ptr ub = boost::dynamic_pointer_cast (c); + if (ub) { + + std::vector::iterator i = _bundles_connected_to_outputs.begin(); + while (i != _bundles_connected_to_outputs.end() && i->bundle != ub) { + ++i; + } + + if (i != _bundles_connected_to_outputs.end()) { + _bundles_connected_to_outputs.erase (i); + } + } + } + + output_changed (IOChange (ConfigurationChanged|ConnectionsChanged), src); /* EMIT SIGNAL */ + return 0; +} + + int IO::disable_connecting () { diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index 00fae6ac74..ed5ff668aa 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -595,7 +595,11 @@ Session::when_engine_running () BootMessage (_("Set up standard connections")); /* Create a set of Bundle objects that map - to the physical I/O currently available */ + to the physical I/O currently available. We create both + mono and stereo bundles, so that the common cases of mono + and stereo tracks get bundles to put in their mixer strip + in / out menus. There may be a nicer way of achieving that; + it doesn't really scale that well to higher channel counts */ for (uint32_t np = 0; np < n_physical_outputs; ++np) { char buf[32]; @@ -608,6 +612,20 @@ Session::when_engine_running () add_bundle (c); } + for (uint32_t np = 0; np < n_physical_outputs; np += 2) { + if (np + 1 < n_physical_outputs) { + char buf[32]; + snprintf (buf, sizeof(buf), _("out %" PRIu32 "+%" PRIu32), np + 1, np + 2); + shared_ptr c (new Bundle (buf, true)); + c->add_channel (_("L")); + c->set_port (0, _engine.get_nth_physical_output (DataType::AUDIO, np)); + c->add_channel (_("R")); + c->set_port (1, _engine.get_nth_physical_output (DataType::AUDIO, np + 1)); + + add_bundle (c); + } + } + for (uint32_t np = 0; np < n_physical_inputs; ++np) { char buf[32]; snprintf (buf, sizeof (buf), _("in %" PRIu32), np+1); @@ -619,6 +637,21 @@ Session::when_engine_running () add_bundle (c); } + for (uint32_t np = 0; np < n_physical_inputs; np += 2) { + if (np + 1 < n_physical_inputs) { + char buf[32]; + snprintf (buf, sizeof(buf), _("in %" PRIu32 "+%" PRIu32), np + 1, np + 2); + + shared_ptr c (new Bundle (buf, false)); + c->add_channel (_("L")); + c->set_port (0, _engine.get_nth_physical_input (DataType::AUDIO, np)); + c->add_channel (_("R")); + c->set_port (1, _engine.get_nth_physical_input (DataType::AUDIO, np + 1)); + + add_bundle (c); + } + } + if (_master_out) { /* create master/control ports */ -- cgit v1.2.3