From: Carl Hetherington Date: Mon, 15 Apr 2019 11:34:06 +0000 (+0100) Subject: Report playback latency for PulseAudio. X-Git-Url: https://main.carlh.net/gitweb/?p=rtaudio-cdist.git;a=commitdiff_plain;h=350f2d101a5157103604a52c6e0bd88b23d620e0;hp=e46da8995672eda8500a8567c3edcdeef9b44e3d Report playback latency for PulseAudio. --- diff --git a/RtAudio.cpp b/RtAudio.cpp index 1b27de1..264d5f6 100644 --- a/RtAudio.cpp +++ b/RtAudio.cpp @@ -8640,6 +8640,14 @@ void RtApiPulse::callbackEvent( void ) MUTEX_UNLOCK( &stream_.mutex ); RtApi::tickStreamTime(); + if (pah->s_play) { + int e = 0; + pa_usec_t const lat = pa_simple_get_latency(pah->s_play, &e); + if (e == 0) { + stream_.latency[0] = lat * stream_.sampleRate / 1000000; + } + } + if ( doStopStream == 1 ) stopStream(); }