Fix up port matrix for new Route / IO arrangements.
authorCarl Hetherington <carl@carlh.net>
Tue, 9 Jun 2009 23:43:20 +0000 (23:43 +0000)
committerCarl Hetherington <carl@carlh.net>
Tue, 9 Jun 2009 23:43:20 +0000 (23:43 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@5143 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/port_group.cc
gtk2_ardour/port_group.h

index 99c4861f792a6ce9171d157304e5e47c6fe446e8..0aae51d2b926810b672786f6dd88a802aee8f10c 100644 (file)
@@ -149,7 +149,7 @@ PortGroupList::set_type (DataType t)
 }
 
 void
-PortGroupList::maybe_add_processor_to_bundle (boost::weak_ptr<Processor> wp, boost::shared_ptr<RouteBundle> rb, bool inputs)
+PortGroupList::maybe_add_processor_to_bundle (boost::weak_ptr<Processor> wp, boost::shared_ptr<RouteBundle> rb, bool inputs, set<boost::shared_ptr<IO> >& used_io)
 {
        boost::shared_ptr<Processor> p (wp.lock());
 
@@ -160,18 +160,13 @@ PortGroupList::maybe_add_processor_to_bundle (boost::weak_ptr<Processor> wp, boo
        boost::shared_ptr<IOProcessor> iop = boost::dynamic_pointer_cast<IOProcessor> (p);
        
        if (iop) {
+
+               boost::shared_ptr<IO> 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<PortGroup> 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<RouteList> routes = session.get_routes ();
 
        for (RouteList::const_iterator i = routes->begin(); i != routes->end(); ++i) {
 
-               boost::shared_ptr<RouteBundle> 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<boost::shared_ptr<IO> > used_io;
+               boost::shared_ptr<IO> io = inputs ? (*i)->input() : (*i)->output();
+               used_io.insert (io);
+               
+               boost::shared_ptr<RouteBundle> 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<PortGroup> g;
index 707cc0496693e17f86eee1739e83ecfe448c6789..5abe0c9bcd8871b50166deacdc427a43d27757a8 100644 (file)
@@ -22,6 +22,7 @@
 
 #include <vector>
 #include <string>
+#include <set>
 #include <gtkmm/widget.h>
 #include <gtkmm/checkbutton.h>
 #include <boost/shared_ptr.hpp>
@@ -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<std::string> const &, std::string const &) const;
        void emit_changed ();
        boost::shared_ptr<ARDOUR::Bundle> make_bundle_from_ports (std::vector<std::string> const &, bool) const;
-       void maybe_add_processor_to_bundle (boost::weak_ptr<ARDOUR::Processor>, boost::shared_ptr<RouteBundle>, bool);
+       void maybe_add_processor_to_bundle (boost::weak_ptr<ARDOUR::Processor>, boost::shared_ptr<RouteBundle>, bool, std::set<boost::shared_ptr<ARDOUR::IO> > &);
 
        ARDOUR::DataType _type;
        mutable ARDOUR::BundleList _bundles;