alsa: protect against impossible timeouts

Check if the new timeout is larger than 1sec in the past or future
and reprogram a timeout with a saner timeout.
This commit is contained in:
Wim Taymans 2022-02-15 15:35:40 +01:00
parent 8b899dbc55
commit 87f4726164

View file

@ -2345,6 +2345,13 @@ static void alsa_on_timeout_event(struct spa_source *source)
handle_capture(state, current_time, delay, target);
done:
if (state->next_time > current_time + SPA_NSEC_PER_SEC ||
current_time > state->next_time + SPA_NSEC_PER_SEC) {
spa_log_error(state->log, "%s: impossible timeout %lu %lu %"PRIu64" %"PRIu64" %"PRIi64
" %d %"PRIi64, state->props.device, delay, target, current_time, state->next_time,
state->next_time - current_time, state->threshold, state->sample_count);
state->next_time = current_time + state->threshold * 1e9 / state->rate;
}
set_timeout(state, state->next_time);
}