use an explicit black list of route names that require numbering.
authorPaul Davis <paul@linuxaudiosystems.com>
Mon, 14 Sep 2015 14:47:21 +0000 (10:47 -0400)
committerPaul Davis <paul@linuxaudiosystems.com>
Tue, 15 Sep 2015 13:00:50 +0000 (09:00 -0400)
This replaces an attempt to check port names which fails for a number of reasons.

libs/ardour/session.cc

index 46f8b18b6e58ef871c8a8e078c4e659cfb2b3368..43b5790228b8324d31e09835c3d46010ed579bee 100644 (file)
@@ -2201,37 +2201,46 @@ Session::resort_routes_using (boost::shared_ptr<RouteList> r)
 bool
 Session::find_route_name (string const & base, uint32_t& id, string& name, bool definitely_add_number)
 {
-       string el_base = base;
+       /* it is unfortunate that we need to include reserved names here that
+          refer to control surfaces. But there's no way to ensure a complete
+          lack of collisions without doing this, since the control surface
+          support may not even be active. Without adding an API to control 
+          surface support that would list their port names, we do have to
+          list them here.
+       */
+
+       char const * const reserved[] = {
+               _("Monitor"),
+               _("Master"),
+               _("Control"),
+               _("Click"),
+               _("Mackie"),
+               0
+       };
        
        /* the base may conflict with ports that do not belong to existing
           routes, but hidden objects like the click track. So check port names
           before anything else.
        */
-
        
-       if (!_engine.port_name_prefix_is_unique (base)) {
-               uint32_t unique_port_suffix = 1;
-
-               do {
-                       string possible = string_compose (X_("%1-%2"), base, unique_port_suffix);
-                       if (_engine.port_name_prefix_is_unique (possible)) {
-                               el_base = possible;
-                               break;
+       for (int n = 0; reserved[n]; ++n) {
+               if (base == reserved[n]) {
+                       definitely_add_number = true;
+                       if (id < 1) {
+                               id = 1;
                        }
-
-                       unique_port_suffix++;
-
-               } while (unique_port_suffix < UINT_MAX);
+                       break;
+               }
        }
-
-       if (!definitely_add_number && route_by_name (el_base) == 0) {
+       
+       if (!definitely_add_number && route_by_name (base) == 0) {
                /* juse use the base */
-               name = el_base;
+               name = base;
                return true;
        }
 
        do {
-               name = string_compose ("%1 %2", el_base, id);
+               name = string_compose ("%1 %2", base, id);
 
                if (route_by_name (name) == 0) {
                        return true;