Fix callback order of port-dis/connections

Previously the port-engine was a LIFO. Changes were pushed back
and then popped-back. This causes issues when re-connecting
Transport Masters.

The GUI does the following when changing connections:
1. disconnect all
2. connect to new port

which lead to TransportMaster::connection_handler being called
in reverse order: connect, disconnect, and the transport
master was assumed to not be connected.

--

Now connections queue is a FIFO and code was consolidated.

(Note, we cannot use a std::deque because it does not support
memory pre-allocation with ::reserve)
This commit is contained in:
Robin Gareus 2023-12-02 23:34:58 +01:00
parent 1386b3b73f
commit dacf488c86
No known key found for this signature in database
GPG key ID: A090BCE02CF57F04
7 changed files with 18 additions and 31 deletions

View file

@ -1282,12 +1282,7 @@ CoreAudioBackend::pre_process ()
if (!_port_connection_queue.empty ()) {
connections_changed = true;
}
while (!_port_connection_queue.empty ()) {
PortConnectData *c = _port_connection_queue.back ();
manager.connect_callback (c->a, c->b, c->c);
_port_connection_queue.pop_back ();
delete c;
}
process_connection_queue_locked (manager);
pthread_mutex_unlock (&_port_callback_mutex);
}
if (ports_changed) {