Clean up b5e479df and expose API to queue latency-updates

This commit is contained in:
Robin Gareus 2020-07-12 00:38:56 +02:00
parent b5e479dfc3
commit 1796ee60b2
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
2 changed files with 33 additions and 23 deletions

View File

@ -210,8 +210,7 @@ class LIBARDOUR_API AudioEngine : public PortManager, public SessionHandlePtr
static void destroy();
void died ();
/* The backend will cause these at the appropriate time(s)
*/
/* The backend will cause these at the appropriate time(s) */
int process_callback (pframes_t nframes);
int buffer_size_change (pframes_t nframes);
int sample_rate_change (pframes_t nframes);
@ -259,6 +258,7 @@ class LIBARDOUR_API AudioEngine : public PortManager, public SessionHandlePtr
void reset_silence_countdown ();
void add_pending_port_deletion (Port*);
void queue_latency_update (bool);
private:
AudioEngine ();

View File

@ -1416,27 +1416,37 @@ void
AudioEngine::latency_callback (bool for_playback)
{
DEBUG_TRACE (DEBUG::BackendCallbacks, string_compose (X_("latency callback playback ? %1\n"), for_playback));
if (_session) {
if (in_process_thread ()) {
/* internal backends emit the latency callback in the rt-callback,
* async to connect/disconnect or port creation/deletion.
* All is fine.
*
* However jack 1/2 emit the callback in sync with creating the port
* (or while handling the connection change).
* e.g. JACK2 jack_port_register() blocks and the jack_latency_callback
* from a different thread: https://pastebin.com/mitGBwpq
* but at this point in time Ardour still holds the process callback
* because JACK2 can process in parallel to latency callbacks.
*
* see also Session::update_latency() and git-ref 1983f56592dfea5f7498
*/
_session->update_latency (for_playback);
} else if (for_playback) {
g_atomic_int_set (&_pending_playback_latency_callback, 1);
} else {
g_atomic_int_set (&_pending_capture_latency_callback, 1);
}
if (!_session) {
return;
}
if (in_process_thread ()) {
/* internal backends emit the latency callback in the rt-callback,
* async to connect/disconnect or port creation/deletion.
* All is fine.
*/
_session->update_latency (for_playback);
} else {
/* However jack 1/2 emit the callback in sync with creating the port
* (or while handling the connection change).
* e.g. JACK2 jack_port_register() blocks and the jack_latency_callback
* from a different thread: https://pastebin.com/mitGBwpq
* but at this point in time Ardour still holds the process callback
* because JACK2 can process in parallel to latency callbacks.
*
* see also Session::update_latency() and git-ref 1983f56592dfea5f7498
*/
queue_latency_update (for_playback);
}
}
void
AudioEngine::queue_latency_update (bool for_playback)
{
if (for_playback) {
g_atomic_int_set (&_pending_playback_latency_callback, 1);
} else {
g_atomic_int_set (&_pending_capture_latency_callback, 1);
}
}