Check for reserved i/o that are not routes, fixes #7171
authorRobin Gareus <robin@gareus.org>
Sat, 10 Dec 2016 23:03:44 +0000 (00:03 +0100)
committerRobin Gareus <robin@gareus.org>
Sat, 10 Dec 2016 23:04:08 +0000 (00:04 +0100)
libs/ardour/ardour/ardour.h
libs/ardour/globals.cc
libs/ardour/session.cc

index 79b69124ac2a39a127359808e25cf5dcd5c58c4f..c86c59eb0305fc0186594de4fba8bc419a26d83d 100644 (file)
@@ -52,7 +52,7 @@ namespace ARDOUR {
        extern LIBARDOUR_API PBD::Signal1<void,int> PluginScanTimeout;
        extern LIBARDOUR_API PBD::Signal0<void> GUIIdle;
        extern LIBARDOUR_API PBD::Signal3<bool,std::string,std::string,int> CopyConfigurationFiles;
-       extern LIBARDOUR_API std::vector<std::string> reserved_io_names;
+       extern LIBARDOUR_API std::map<std::string, bool> reserved_io_names;
 
        /**
         * @param with_vst true to enable VST Support
index 974247aef57cb08d26daebf280485cee9bc1da8e..45ac987eb13de5773b1e72806344f51738534826 100644 (file)
@@ -144,7 +144,7 @@ PBD::Signal1<void,int> ARDOUR::PluginScanTimeout;
 PBD::Signal0<void> ARDOUR::GUIIdle;
 PBD::Signal3<bool,std::string,std::string,int> ARDOUR::CopyConfigurationFiles;
 
-std::vector<std::string> ARDOUR::reserved_io_names;
+std::map<std::string, bool> ARDOUR::reserved_io_names;
 
 static bool have_old_configuration_files = false;
 
@@ -544,20 +544,17 @@ ARDOUR::init (bool use_windows_vst, bool try_optimization, const char* localedir
           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.
+
+          We also need to know if the given I/O is an actual route.
+          For routes (e.g. "master"), bus creation needs to be allowed the first time,
+          while for pure I/O (e.g. "Click") track/bus creation must always fail.
        */
 
-       char const * const reserved[] = {
-               _("Monitor"),
-               _("Master"),
-               _("Control"),
-               _("Click"),
-               _("Mackie"),
-               0
-       };
-
-       for (int n = 0; reserved[n]; ++n) {
-               reserved_io_names.push_back (reserved[n]);
-       }
+       reserved_io_names[_("Monitor")] = true;
+       reserved_io_names[_("Master")] = true;
+       reserved_io_names[_("Control")] = false;
+       reserved_io_names[_("Click")] = false;
+       reserved_io_names[_("Mackie")] = false;
 
        libardour_initialized = true;
 
index 4bf070dc213af406e9565206c82dba43e269cab6..4f005b1001a802c77cc11128ba4f7d22272def5f 100644 (file)
@@ -2366,12 +2366,12 @@ Session::find_route_name (string const & base, uint32_t& id, string& name, bool
           before anything else.
        */
 
-       for (vector<string>::const_iterator reserved = reserved_io_names.begin(); reserved != reserved_io_names.end(); ++reserved) {
-               if (base == *reserved) {
+       for (map<string,bool>::const_iterator reserved = reserved_io_names.begin(); reserved != reserved_io_names.end(); ++reserved) {
+               if (base == reserved->first) {
                        /* Check if this reserved name already exists, and if
                           so, disallow it without a numeric suffix.
                        */
-                       if (route_by_name (*reserved)) {
+                       if (!reserved->second || route_by_name (reserved->first)) {
                                definitely_add_number = true;
                                if (id < 1) {
                                        id = 1;
@@ -4075,9 +4075,9 @@ Session::io_name_is_legal (const std::string& name) const
 {
        boost::shared_ptr<RouteList> r = routes.reader ();
 
-       for (vector<string>::const_iterator reserved = reserved_io_names.begin(); reserved != reserved_io_names.end(); ++reserved) {
-               if (name == *reserved) {
-                       if (!route_by_name (*reserved)) {
+       for (map<string,bool>::const_iterator reserved = reserved_io_names.begin(); reserved != reserved_io_names.end(); ++reserved) {
+               if (name == reserved->first) {
+                       if (!route_by_name (reserved->first)) {
                                /* first instance of a reserved name is allowed */
                                return true;
                        }