Report playback latency for PulseAudio.
authorCarl Hetherington <cth@carlh.net>
Mon, 15 Apr 2019 11:34:06 +0000 (12:34 +0100)
committerCarl Hetherington <cth@carlh.net>
Mon, 15 Apr 2019 19:48:45 +0000 (20:48 +0100)
RtAudio.cpp

index 1b27de1fd5c60f883c1842d9d36272828195bb15..264d5f694c2b0fd0187f6957107554280b63cfab 100644 (file)
@@ -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();
 }