From b40826792abbb1a503c8ddbf7ae1b985e50f0599 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Sat, 5 Sep 2020 23:05:18 +0200 Subject: [PATCH] Fix port-connection callbacks on engine restart When the engine is restarted, ports are re-established, and previously queued port-connections need to be cleared. This caused a bug: * when the engine is stopped all ports are disconnected. _port_connection_queue contains all disconnections * engine is stopped so _port_connection_queue is not processed * engine-restart re-etablishes ports and appends those connections to _port_connection_queue * process-callback processes the list in **reverse** order ``` while (!_port_connection_queue.empty ()) { _port_connection_queue.pop_back (); } ``` * ARDOUR::PortManager::connect_callback() is first called with connected() and the disconnected() * All ports are assumed to not be connected Port::_externally_connected == 0 for all ports Result: * vari-speed playback resampling does not work (only external I/O is reampled), split cycles processing (looping) fails since AudioPort::get_audio_buffer() does not apply the _global_port_buffer_offset --- libs/ardour/port_engine_shared.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libs/ardour/port_engine_shared.cc b/libs/ardour/port_engine_shared.cc index 4de619497f..1e9e26a93b 100644 --- a/libs/ardour/port_engine_shared.cc +++ b/libs/ardour/port_engine_shared.cc @@ -435,6 +435,10 @@ PortEngineSharedImpl::clear_ports () _ports.flush (); _portmap.flush (); + pthread_mutex_lock (&_port_callback_mutex); + _port_change_flag = false; + _port_connection_queue.clear(); + pthread_mutex_unlock (&_port_callback_mutex); } uint32_t