From 3dab0091bbc99b041703ece8c39df32610217e25 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Thu, 29 Jun 2023 15:56:43 +0200 Subject: [PATCH] alsa: warn when the htimestamp seems wrong The htimestamp should be close to the current_time, if it is further away that the threshold, something is wrong. --- spa/plugins/alsa/alsa-pcm.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/spa/plugins/alsa/alsa-pcm.c b/spa/plugins/alsa/alsa-pcm.c index 3abf3b6ef..6c8899d11 100644 --- a/spa/plugins/alsa/alsa-pcm.c +++ b/spa/plugins/alsa/alsa-pcm.c @@ -2014,7 +2014,12 @@ static int get_avail(struct state *state, uint64_t current_time, snd_pcm_uframes spa_log_trace_fp(state->log, "%"PRIu64" %"PRIu64" %"PRIi64, current_time, then, diff); - *delay += diff; + if (SPA_ABS(diff) < state->threshold) { + *delay += diff; + } else if ((missed = ratelimit_test(&state->rate_limit, current_time)) >= 0) { + spa_log_warn(state->log, "%s: (%d missed) impossible htimestamp diff:%"PRIi64, + state->props.device, missed, diff); + } } return SPA_MIN(avail, state->buffer_frames); }