Handle JACK latency callbacks in sync with process thread #8304

see also b5e479dfc3
This commit is contained in:
Robin Gareus 2021-02-20 00:46:32 +01:00
parent 3f4e2fa348
commit 4a5b355d3d
No known key found for this signature in database
GPG key ID: A090BCE02CF57F04
2 changed files with 18 additions and 2 deletions

View file

@ -288,13 +288,27 @@ AudioEngine::process_callback (pframes_t nframes)
* port registration (usually while ardour holds the process-lock
* or with _adding_routes_in_progress or _route_deletion_in_progress set,
* potentially while processing in parallel.
*
* Note: this must be done without holding the _process_lock
*/
if (_session) {
bool lp = false;
bool lc = false;
if (g_atomic_int_compare_and_exchange (&_pending_playback_latency_callback, 1, 0)) {
_session->update_latency (true);
lp = true;
}
if (g_atomic_int_compare_and_exchange (&_pending_capture_latency_callback, 1, 0)) {
_session->update_latency (false);
lc = true;
}
if (lp || lc) {
tm.release ();
if (lp) {
_session->update_latency (true);
}
if (lc) {
_session->update_latency (false);
}
tm.acquire ();
}
}

View file

@ -4861,6 +4861,8 @@ Route::update_port_latencies (PortSet& from, PortSet& to, bool playback, samplec
p->set_private_latency_range (all_connections, playback);
}
DEBUG_TRACE (DEBUG::LatencyRoute, string_compose ("%1: priv. port L(%2) = (%3, %4) + %5\n", _name, playback ? "playback" : "capture", all_connections.min, all_connections.max, our_latency));
/* set the ports "in the direction of the flow" to the same value as above plus our own signal latency */
all_connections.min += our_latency;