move speed quietning code into Delivery, where it belongs.
[ardour.git] / libs / ardour / session.cc
index c3eca166df072c708b9f9c1156a81f1f731d4533..43b5790228b8324d31e09835c3d46010ed579bee 100644 (file)
@@ -1028,10 +1028,13 @@ Session::add_monitor_section ()
 #ifdef BOOST_SP_ENABLE_DEBUG_HOOKS
        // boost_debug_shared_ptr_mark_interesting (r.get(), "Route");
 #endif
-       {
+       try {
                Glib::Threads::Mutex::Lock lm (AudioEngine::instance()->process_lock ());
                r->input()->ensure_io (_master_out->output()->n_ports(), false, this);
                r->output()->ensure_io (_master_out->output()->n_ports(), false, this);
+       } catch (...) {
+               error << _("Cannot create monitor section. 'Monitor' Port name is not unique.") << endmsg;
+               return;
        }
 
        rl.push_back (r);
@@ -2198,6 +2201,38 @@ 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)
 {
+       /* 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.
+       */
+       
+       for (int n = 0; reserved[n]; ++n) {
+               if (base == reserved[n]) {
+                       definitely_add_number = true;
+                       if (id < 1) {
+                               id = 1;
+                       }
+                       break;
+               }
+       }
+       
        if (!definitely_add_number && route_by_name (base) == 0) {
                /* juse use the base */
                name = base;