From 39903a00235a6bd222da23bab177a960ce1c5947 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Sun, 11 Dec 2016 00:03:44 +0100 Subject: [PATCH] Check for reserved i/o that are not routes, fixes #7171 --- libs/ardour/ardour/ardour.h | 2 +- libs/ardour/globals.cc | 23 ++++++++++------------- libs/ardour/session.cc | 12 ++++++------ 3 files changed, 17 insertions(+), 20 deletions(-) diff --git a/libs/ardour/ardour/ardour.h b/libs/ardour/ardour/ardour.h index 79b69124ac..c86c59eb03 100644 --- a/libs/ardour/ardour/ardour.h +++ b/libs/ardour/ardour/ardour.h @@ -52,7 +52,7 @@ namespace ARDOUR { extern LIBARDOUR_API PBD::Signal1 PluginScanTimeout; extern LIBARDOUR_API PBD::Signal0 GUIIdle; extern LIBARDOUR_API PBD::Signal3 CopyConfigurationFiles; - extern LIBARDOUR_API std::vector reserved_io_names; + extern LIBARDOUR_API std::map reserved_io_names; /** * @param with_vst true to enable VST Support diff --git a/libs/ardour/globals.cc b/libs/ardour/globals.cc index 974247aef5..45ac987eb1 100644 --- a/libs/ardour/globals.cc +++ b/libs/ardour/globals.cc @@ -144,7 +144,7 @@ PBD::Signal1 ARDOUR::PluginScanTimeout; PBD::Signal0 ARDOUR::GUIIdle; PBD::Signal3 ARDOUR::CopyConfigurationFiles; -std::vector ARDOUR::reserved_io_names; +std::map 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; diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index 4bf070dc21..4f005b1001 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -2366,12 +2366,12 @@ Session::find_route_name (string const & base, uint32_t& id, string& name, bool before anything else. */ - for (vector::const_iterator reserved = reserved_io_names.begin(); reserved != reserved_io_names.end(); ++reserved) { - if (base == *reserved) { + for (map::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 r = routes.reader (); - for (vector::const_iterator reserved = reserved_io_names.begin(); reserved != reserved_io_names.end(); ++reserved) { - if (name == *reserved) { - if (!route_by_name (*reserved)) { + for (map::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; } -- 2.30.2