From d039e2e80ff2179aef7430c53ca41e43297d9065 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 9 Jun 2009 23:43:20 +0000 Subject: Fix up port matrix for new Route / IO arrangements. git-svn-id: svn://localhost/ardour2/branches/3.0@5143 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/port_group.cc | 30 ++++++++++++++++-------------- gtk2_ardour/port_group.h | 4 +++- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/gtk2_ardour/port_group.cc b/gtk2_ardour/port_group.cc index 99c4861f79..0aae51d2b9 100644 --- a/gtk2_ardour/port_group.cc +++ b/gtk2_ardour/port_group.cc @@ -149,7 +149,7 @@ PortGroupList::set_type (DataType t) } void -PortGroupList::maybe_add_processor_to_bundle (boost::weak_ptr wp, boost::shared_ptr rb, bool inputs) +PortGroupList::maybe_add_processor_to_bundle (boost::weak_ptr wp, boost::shared_ptr rb, bool inputs, set >& used_io) { boost::shared_ptr p (wp.lock()); @@ -160,18 +160,13 @@ PortGroupList::maybe_add_processor_to_bundle (boost::weak_ptr wp, boo boost::shared_ptr iop = boost::dynamic_pointer_cast (p); if (iop) { + + boost::shared_ptr io = inputs ? iop->input() : iop->output(); - if (inputs) { - if (!iop->output()) { - return; - } - } else { - if (!iop->input()) { - return; - } + if (io && used_io.find (io) == used_io.end()) { + rb->add_processor_bundle (io->bundle ()); + used_io.insert (io); } - - rb->add_processor_bundle (inputs ? iop->output()->bundle() : iop->input()->bundle()); } } @@ -188,16 +183,23 @@ PortGroupList::gather (Session& session, bool inputs) boost::shared_ptr other (new PortGroup (_("Other"))); /* Find the bundles for routes. We use the RouteBundle class to join - the route's IO bundles and processor bundles together so that they + the route's input/output and processor bundles together so that they are presented as one bundle in the matrix. */ boost::shared_ptr routes = session.get_routes (); for (RouteList::const_iterator i = routes->begin(); i != routes->end(); ++i) { - boost::shared_ptr rb (new RouteBundle (inputs ? (*i)->output()->bundle() : (*i)->input()->bundle())); + /* keep track of IOs that we have taken bundles from, so that maybe_add_processor... below + can avoid taking the same IO from both Route::output() and the main_outs Delivery */ + + set > used_io; + boost::shared_ptr io = inputs ? (*i)->input() : (*i)->output(); + used_io.insert (io); + + boost::shared_ptr rb (new RouteBundle (io->bundle())); - (*i)->foreach_processor (bind (mem_fun (*this, &PortGroupList::maybe_add_processor_to_bundle), rb, inputs)); + (*i)->foreach_processor (bind (mem_fun (*this, &PortGroupList::maybe_add_processor_to_bundle), rb, inputs, used_io)); /* Work out which group to put this bundle in */ boost::shared_ptr g; diff --git a/gtk2_ardour/port_group.h b/gtk2_ardour/port_group.h index 707cc04966..5abe0c9bcd 100644 --- a/gtk2_ardour/port_group.h +++ b/gtk2_ardour/port_group.h @@ -22,6 +22,7 @@ #include #include +#include #include #include #include @@ -32,6 +33,7 @@ namespace ARDOUR { class Session; class Bundle; class Processor; + class IO; } class PortMatrix; @@ -121,7 +123,7 @@ class PortGroupList : public sigc::trackable std::string common_prefix_before (std::vector const &, std::string const &) const; void emit_changed (); boost::shared_ptr make_bundle_from_ports (std::vector const &, bool) const; - void maybe_add_processor_to_bundle (boost::weak_ptr, boost::shared_ptr, bool); + void maybe_add_processor_to_bundle (boost::weak_ptr, boost::shared_ptr, bool, std::set > &); ARDOUR::DataType _type; mutable ARDOUR::BundleList _bundles; -- cgit v1.2.3