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
No known key found for this signature in database
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(); static void destroy();
void died (); 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 process_callback (pframes_t nframes);
int buffer_size_change (pframes_t nframes); int buffer_size_change (pframes_t nframes);
int sample_rate_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 reset_silence_countdown ();
void add_pending_port_deletion (Port*); void add_pending_port_deletion (Port*);
void queue_latency_update (bool);
private: private:
AudioEngine (); AudioEngine ();

View file

@ -1416,13 +1416,18 @@ void
AudioEngine::latency_callback (bool for_playback) AudioEngine::latency_callback (bool for_playback)
{ {
DEBUG_TRACE (DEBUG::BackendCallbacks, string_compose (X_("latency callback playback ? %1\n"), for_playback)); DEBUG_TRACE (DEBUG::BackendCallbacks, string_compose (X_("latency callback playback ? %1\n"), for_playback));
if (_session) { if (!_session) {
return;
}
if (in_process_thread ()) { if (in_process_thread ()) {
/* internal backends emit the latency callback in the rt-callback, /* internal backends emit the latency callback in the rt-callback,
* async to connect/disconnect or port creation/deletion. * async to connect/disconnect or port creation/deletion.
* All is fine. * All is fine.
* */
* However jack 1/2 emit the callback in sync with creating the port _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). * (or while handling the connection change).
* e.g. JACK2 jack_port_register() blocks and the jack_latency_callback * e.g. JACK2 jack_port_register() blocks and the jack_latency_callback
* from a different thread: https://pastebin.com/mitGBwpq * from a different thread: https://pastebin.com/mitGBwpq
@ -1431,14 +1436,19 @@ AudioEngine::latency_callback (bool for_playback)
* *
* see also Session::update_latency() and git-ref 1983f56592dfea5f7498 * see also Session::update_latency() and git-ref 1983f56592dfea5f7498
*/ */
_session->update_latency (for_playback); queue_latency_update (for_playback);
} else if (for_playback) { }
}
void
AudioEngine::queue_latency_update (bool for_playback)
{
if (for_playback) {
g_atomic_int_set (&_pending_playback_latency_callback, 1); g_atomic_int_set (&_pending_playback_latency_callback, 1);
} else { } else {
g_atomic_int_set (&_pending_capture_latency_callback, 1); g_atomic_int_set (&_pending_capture_latency_callback, 1);
} }
} }
}
void void
AudioEngine::update_latencies () AudioEngine::update_latencies ()