Skip to content

Commit feb0790

Browse files
committed
aplay/pipewire: Report playback latency
1 parent 20304e0 commit feb0790

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/audio/playback/pipewire.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,17 @@ static bool audio_play_pw_reconfigure(void *state, struct audio_desc desc){
331331
const char *error = nullptr;
332332
auto stream_state = pw_stream_get_state(s->stream.get(), &error);
333333
if(stream_state == PW_STREAM_STATE_STREAMING){
334+
pw_time time;
335+
float delay = 0;
336+
#if PW_MAJOR > 0 || PW_MINOR > 3 || (PW_MINOR == 3 && PW_MICRO >= 50)
337+
pw_stream_get_time_n(s->stream.get(), &time, sizeof(time));
338+
delay += time.buffered * 1000.f / rate;
339+
#else
340+
pw_stream_get_time(s->stream.get(), &time);
341+
#endif
342+
343+
delay += time.delay * 1000.f * time.rate.num / time.rate.denom;
344+
log_msg(LOG_LEVEL_NOTICE, MOD_NAME "Successfully reconfigured and pipewire reports %.2fms of playback delay\n", delay);
334345
return true;
335346
}
336347
if(stream_state == PW_STREAM_STATE_ERROR){

0 commit comments

Comments
 (0)