another TLSF vs realloc-pool shootout
[ardour.git] / gtk2_ardour / port_group.cc
index d02171a2b1b2679677f8fa14820469e837f9260f..084514363a3bd90ff0d5af2b51f5fb66be9fa942 100644 (file)
@@ -43,7 +43,7 @@
 #include "time_axis_view.h"
 #include "public_editor.h"
 
-#include "i18n.h"
+#include "pbd/i18n.h"
 
 using namespace std;
 using namespace Gtk;
@@ -316,7 +316,7 @@ struct RouteIOs {
 class RouteIOsComparator {
 public:
        bool operator() (RouteIOs const & a, RouteIOs const & b) {
-               return a.route->order_key () < b.route->order_key ();
+               return a.route->presentation_info ().order() < b.route->presentation_info().order();
        }
 };
 
@@ -375,13 +375,10 @@ PortGroupList::gather (ARDOUR::Session* session, ARDOUR::DataType type, bool inp
        /* Sort RouteIOs by the routes' editor order keys */
        route_ios.sort (RouteIOsComparator ());
 
-       /* Now put the bundles that belong to these sorted RouteIOs into the PortGroup.
-          Note that if the RouteIO's bundles are multi-type, we may make new Bundles
-          with only the ports of one type.
-       */
+       /* Now put the bundles that belong to these sorted RouteIOs into the PortGroup. */
 
        for (list<RouteIOs>::iterator i = route_ios.begin(); i != route_ios.end(); ++i) {
-               TimeAxisView* tv = PublicEditor::instance().axis_view_from_route (i->route);
+               TimeAxisView* tv = PublicEditor::instance().axis_view_from_stripable (i->route);
 
                /* Work out which group to put these IOs' bundles in */
                boost::shared_ptr<PortGroup> g;
@@ -392,10 +389,14 @@ PortGroupList::gather (ARDOUR::Session* session, ARDOUR::DataType type, bool inp
                }
 
                for (list<boost::shared_ptr<IO> >::iterator j = i->ios.begin(); j != i->ios.end(); ++j) {
-                       if (tv) {
-                               g->add_bundle ((*j)->bundle(), *j, tv->color ());
-                       } else {
-                               g->add_bundle ((*j)->bundle(), *j);
+                       /* Only add the bundle if there is at least one port
+                        * with a type that's been asked for */
+                       if (type == DataType::NIL || (*j)->bundle()->nchannels().n(type) > 0) {
+                               if (tv) {
+                                       g->add_bundle ((*j)->bundle(), *j, tv->color ());
+                               } else {
+                                       g->add_bundle ((*j)->bundle(), *j);
+                               }
                        }
                }
        }
@@ -511,7 +512,18 @@ PortGroupList::gather (ARDOUR::Session* session, ARDOUR::DataType type, bool inp
         lpnc += ':';
 
        vector<string> ports;
-       if (AudioEngine::instance()->get_ports ("", type, inputs ? IsInput : IsOutput, ports) > 0) {
+       if (type == DataType::NIL) {
+               vector<string> p1;
+               AudioEngine::instance()->get_ports ("", DataType::AUDIO, inputs ? IsInput : IsOutput, ports);
+               AudioEngine::instance()->get_ports ("", DataType::MIDI, inputs ? IsInput : IsOutput, p1);
+               for (vector<string>::const_iterator s = p1.begin(); s != p1.end(); ++s) {
+                       ports.push_back (*s);
+               }
+       } else {
+               AudioEngine::instance()->get_ports ("", type, inputs ? IsInput : IsOutput, ports);
+       }
+
+       if (ports.size () > 0) {
 
                for (vector<string>::const_iterator s = ports.begin(); s != ports.end(); ) {
 
@@ -622,9 +634,7 @@ PortGroupList::gather (ARDOUR::Session* session, ARDOUR::DataType type, bool inp
        }
 
        add_group_if_not_empty (other);
-       if (type != DataType::MIDI) {
-               add_group_if_not_empty (bus);
-       }
+       add_group_if_not_empty (bus);
        add_group_if_not_empty (track);
        add_group_if_not_empty (program);
        add_group_if_not_empty (system);