mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-20 13:46:30 +01:00
use an explicit black list of route names that require numbering.
This replaces an attempt to check port names which fails for a number of reasons.
This commit is contained in:
parent
b05912b0cb
commit
d92fceabb0
1 changed files with 27 additions and 18 deletions
|
|
@ -2201,37 +2201,46 @@ Session::resort_routes_using (boost::shared_ptr<RouteList> r)
|
||||||
bool
|
bool
|
||||||
Session::find_route_name (string const & base, uint32_t& id, string& name, bool definitely_add_number)
|
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
|
/* the base may conflict with ports that do not belong to existing
|
||||||
routes, but hidden objects like the click track. So check port names
|
routes, but hidden objects like the click track. So check port names
|
||||||
before anything else.
|
before anything else.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
for (int n = 0; reserved[n]; ++n) {
|
||||||
if (!_engine.port_name_prefix_is_unique (base)) {
|
if (base == reserved[n]) {
|
||||||
uint32_t unique_port_suffix = 1;
|
definitely_add_number = true;
|
||||||
|
if (id < 1) {
|
||||||
do {
|
id = 1;
|
||||||
string possible = string_compose (X_("%1-%2"), base, unique_port_suffix);
|
}
|
||||||
if (_engine.port_name_prefix_is_unique (possible)) {
|
|
||||||
el_base = possible;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
unique_port_suffix++;
|
|
||||||
|
|
||||||
} while (unique_port_suffix < UINT_MAX);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!definitely_add_number && route_by_name (el_base) == 0) {
|
if (!definitely_add_number && route_by_name (base) == 0) {
|
||||||
/* juse use the base */
|
/* juse use the base */
|
||||||
name = el_base;
|
name = base;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
do {
|
do {
|
||||||
name = string_compose ("%1 %2", el_base, id);
|
name = string_compose ("%1 %2", base, id);
|
||||||
|
|
||||||
if (route_by_name (name) == 0) {
|
if (route_by_name (name) == 0) {
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue