alsa: disable htimestamp when it seems to error too much

This commit is contained in:
Wim Taymans 2023-06-29 16:40:21 +02:00
parent f76191c792
commit 2963e7fd4c
2 changed files with 15 additions and 3 deletions

View file

@ -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);

View file

@ -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;