When reconnecting ports, don't give up on first failure.

If there are multiple connections, one might fail due to missing hardware,
but the rest could still be valid.

An easy way to reproduce this was to route "mackie control out" to a device
and to the Midi tracer port. When you opened the session again, connection
from the "mackie control out" to the device would not get restored because
the Midi tracer port does not exist at session start.

This most likely caused other issues with connections when changing backends.
This commit is contained in:
Todd Naugle 2021-07-13 17:47:33 -05:00
parent 30811989ef
commit ff1d5e7aeb
1 changed files with 13 additions and 6 deletions

View File

@ -560,16 +560,23 @@ Port::reconnect ()
{
/* caller must hold process lock; intended to be used only after reestablish() */
DEBUG_TRACE (DEBUG::Ports, string_compose ("Connect %1 to %2 destinations\n",name(), _connections.size()));
DEBUG_TRACE (DEBUG::Ports, string_compose ("Port::reconnect() Connect %1 to %2 destinations\n",name(), _connections.size()));
for (std::set<string>::iterator i = _connections.begin(); i != _connections.end(); ++i) {
if (connect (*i)) {
_connections.clear ();
return -1;
int count = 0;
std::set<string>::iterator i = _connections.begin();
while (i != _connections.end()) {
std::set<string>::iterator current = i++;
if (connect (*current)) {
DEBUG_TRACE (DEBUG::Ports, string_compose ("Port::reconnect() failed to connect %1 to %2\n", name(), (*current)));
_connections.erase (current);
}
else {
++count;
}
}
return 0;
return count == 0 ? -1 : 0;
}
/** @param n Short port name (no port-system client name) */