diff --git a/spa/plugins/alsa/alsa-pcm.c b/spa/plugins/alsa/alsa-pcm.c index 6478de1c1..dab479091 100644 --- a/spa/plugins/alsa/alsa-pcm.c +++ b/spa/plugins/alsa/alsa-pcm.c @@ -2028,9 +2028,18 @@ static int get_avail_htimestamp(struct state *state, uint64_t current_time, snd_ 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); + state->htimestamp_error = 0; + } else { + if (++state->htimestamp_error > MAX_HTIMESTAMP_ERROR) { + spa_log_error(state->log, "%s: wrong htimestamps from driver, disabling", + state->props.device); + state->htimestamp_error = 0; + state->htimestamp = false; + } + 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); diff --git a/spa/plugins/alsa/alsa-pcm.h b/spa/plugins/alsa/alsa-pcm.h index 3ae9a97de..8b893bb91 100644 --- a/spa/plugins/alsa/alsa-pcm.h +++ b/spa/plugins/alsa/alsa-pcm.h @@ -40,6 +40,8 @@ extern "C" { #define DEFAULT_CHANNELS 2u #define DEFAULT_USE_CHMAP false +#define MAX_HTIMESTAMP_ERROR 64 + struct props { char device[64]; char device_name[128]; @@ -185,6 +187,7 @@ struct state { uint32_t start_delay; uint32_t min_delay; uint32_t max_delay; + uint32_t htimestamp_error; uint32_t duration; unsigned int alsa_started:1;