diff options
author | Carl Hetherington <carl@carlh.net> | 2009-02-02 22:17:06 +0000 |
---|---|---|
committer | Carl Hetherington <carl@carlh.net> | 2009-02-02 22:17:06 +0000 |
commit | 54afc94e62b6397286d545744cea796f93f4b5f9 (patch) | |
tree | 589c5eedfb63e96da410801e1f8cc3d3d4c06cd1 | |
parent | 633629b2b1590b687a79990fe1fb0df35301e709 (diff) |
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
-rw-r--r-- | gtk2_ardour/mixer_strip.cc | 40 | ||||
-rw-r--r-- | gtk2_ardour/mixer_strip.h | 4 | ||||
-rw-r--r-- | gtk2_ardour/port_group.cc | 5 | ||||
-rw-r--r-- | libs/ardour/ardour/bundle.h | 15 | ||||
-rw-r--r-- | libs/ardour/ardour/io.h | 6 | ||||
-rw-r--r-- | libs/ardour/bundle.cc | 37 | ||||
-rw-r--r-- | libs/ardour/io.cc | 91 | ||||
-rw-r--r-- | libs/ardour/session.cc | 35 |
8 files changed, 165 insertions, 68 deletions
diff --git a/gtk2_ardour/mixer_strip.cc b/gtk2_ardour/mixer_strip.cc index 1bee8268ae..fd1650738c 100644 --- a/gtk2_ardour/mixer_strip.cc +++ b/gtk2_ardour/mixer_strip.cc @@ -720,34 +720,34 @@ MixerStrip::input_press (GdkEventButton *ev) } void -MixerStrip::bundle_input_chosen (boost::shared_ptr<ARDOUR::Bundle> c) +MixerStrip::bundle_input_toggled (boost::shared_ptr<ARDOUR::Bundle> c) { - if (!ignore_toggle) { + if (ignore_toggle) { + return; + } - try { - _route->connect_input_ports_to_bundle (c, this); - } + ARDOUR::BundleList current = _route->bundles_connected_to_inputs (); - catch (AudioEngine::PortRegistrationFailure& err) { - error << _("could not register new ports required for that bundle") - << endmsg; - } + if (std::find (current.begin(), current.end(), c) == current.end()) { + _route->connect_input_ports_to_bundle (c, this); + } else { + _route->disconnect_input_ports_from_bundle (c, this); } } void -MixerStrip::bundle_output_chosen (boost::shared_ptr<ARDOUR::Bundle> c) +MixerStrip::bundle_output_toggled (boost::shared_ptr<ARDOUR::Bundle> c) { - if (!ignore_toggle) { + if (ignore_toggle) { + return; + } - try { - _route->connect_output_ports_to_bundle (c, this); - } + ARDOUR::BundleList current = _route->bundles_connected_to_outputs (); - catch (AudioEngine::PortRegistrationFailure& err) { - error << _("could not register new ports required for that bundle") - << endmsg; - } + if (std::find (current.begin(), current.end(), c) == current.end()) { + _route->connect_output_ports_to_bundle (c, this); + } else { + _route->disconnect_output_ports_from_bundle (c, this); } } @@ -766,7 +766,7 @@ MixerStrip::add_bundle_to_input_menu (boost::shared_ptr<Bundle> b, ARDOUR::Bundl if (b->nchannels() == _route->n_inputs().get (b->type ())) { - citems.push_back (CheckMenuElem (b->name(), bind (mem_fun(*this, &MixerStrip::bundle_input_chosen), b))); + citems.push_back (CheckMenuElem (b->name(), bind (mem_fun(*this, &MixerStrip::bundle_input_toggled), b))); if (std::find (current.begin(), current.end(), b) != current.end()) { ignore_toggle = true; @@ -790,7 +790,7 @@ MixerStrip::add_bundle_to_output_menu (boost::shared_ptr<Bundle> b, ARDOUR::Bund if (b->nchannels() == _route->n_outputs().get (b->type ())) { MenuList& citems = output_menu.items(); - citems.push_back (CheckMenuElem (b->name(), bind (mem_fun(*this, &MixerStrip::bundle_output_chosen), b))); + citems.push_back (CheckMenuElem (b->name(), bind (mem_fun(*this, &MixerStrip::bundle_output_toggled), b))); if (std::find (current.begin(), current.end(), b) != current.end()) { ignore_toggle = true; diff --git a/gtk2_ardour/mixer_strip.h b/gtk2_ardour/mixer_strip.h index e859e52026..1b65834270 100644 --- a/gtk2_ardour/mixer_strip.h +++ b/gtk2_ardour/mixer_strip.h @@ -183,8 +183,8 @@ class MixerStrip : public RouteUI, public Gtk::EventBox Gtk::Menu output_menu; void add_bundle_to_output_menu (boost::shared_ptr<ARDOUR::Bundle>, ARDOUR::BundleList const &); - void bundle_input_chosen (boost::shared_ptr<ARDOUR::Bundle>); - void bundle_output_chosen (boost::shared_ptr<ARDOUR::Bundle>); + void bundle_input_toggled (boost::shared_ptr<ARDOUR::Bundle>); + void bundle_output_toggled (boost::shared_ptr<ARDOUR::Bundle>); void edit_input_configuration (); void edit_output_configuration (); diff --git a/gtk2_ardour/port_group.cc b/gtk2_ardour/port_group.cc index 405d503016..d0c56d02a4 100644 --- a/gtk2_ardour/port_group.cc +++ b/gtk2_ardour/port_group.cc @@ -192,11 +192,12 @@ PortGroupList::gather (ARDOUR::Session& session, bool inputs) } } - /* Bundles created by the session */ + /* Bundles created by the session. We only add the mono ones, + otherwise there is duplication of the same ports within the matrix */ boost::shared_ptr<ARDOUR::BundleList> b = session.bundles (); for (ARDOUR::BundleList::iterator i = b->begin(); i != b->end(); ++i) { - if ((*i)->ports_are_inputs() == inputs && (*i)->type() == _type) { + if ((*i)->nchannels() == 1 && (*i)->ports_are_inputs() == inputs && (*i)->type() == _type) { system->add_bundle (*i); } } 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<ARDOUR::Bundle>); + void add_channels_from_bundle (boost::shared_ptr<Bundle>); + void connect (boost::shared_ptr<Bundle>, AudioEngine &); + void disconnect (boost::shared_ptr<Bundle>, 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> &); 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<ARDOUR::Bundle> b, uint32_t c) + BundleChannel (boost::shared_ptr<Bundle> 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<ARDOUR::Bundle> bundle; + boost::shared_ptr<Bundle> 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<Bundle>, void *src); - int connect_output_ports_to_bundle (boost::shared_ptr<Bundle>, void *src); + int connect_input_ports_to_bundle (boost::shared_ptr<Bundle>, void *); + int disconnect_input_ports_from_bundle (boost::shared_ptr<Bundle>, void *); + int connect_output_ports_to_bundle (boost::shared_ptr<Bundle>, void *); + int disconnect_output_ports_from_bundle (boost::shared_ptr<Bundle>, 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 <pbd/failed_constructor.h> #include <ardour/ardour.h> #include <ardour/bundle.h> +#include <ardour/audioengine.h> #include <pbd/xml++.h> #include "i18n.h" @@ -243,3 +244,39 @@ Bundle::add_channels_from_bundle (boost::shared_ptr<Bundle> other) } } } + +void +Bundle::connect (boost::shared_ptr<Bundle> 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<Bundle> 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<Bundle> 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<Bundle> c, void* src) } int -IO::connect_output_ports_to_bundle (boost::shared_ptr<Bundle> c, void* src) +IO::disconnect_input_ports_from_bundle (boost::shared_ptr<Bundle> 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<UserBundle> ub = boost::dynamic_pointer_cast<UserBundle> (c); + if (ub) { - for (Bundle::PortList::const_iterator i = pl.begin(); i != pl.end(); ++i) { + std::vector<UserBundleInfo>::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<Bundle> 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 */ @@ -2155,6 +2148,36 @@ IO::connect_output_ports_to_bundle (boost::shared_ptr<Bundle> c, void* src) } int +IO::disconnect_output_ports_from_bundle (boost::shared_ptr<Bundle> 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<UserBundle> ub = boost::dynamic_pointer_cast<UserBundle> (c); + if (ub) { + + std::vector<UserBundleInfo>::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 () { connecting_legal = false; 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<Bundle> 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<Bundle> 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 */ |