From 71055dce7340f15784000e47c1c5b53293468ded Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Tue, 31 Aug 2021 12:38:18 +0200 Subject: [PATCH] alsa: handle excessive delay values gracefully When we read an excessively large delay value, clamp it to twice the delay so that we don't set our timeout to something too far in the future. --- spa/plugins/alsa/alsa-pcm.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/spa/plugins/alsa/alsa-pcm.c b/spa/plugins/alsa/alsa-pcm.c index b1b85a01d..215b96e0e 100644 --- a/spa/plugins/alsa/alsa-pcm.c +++ b/spa/plugins/alsa/alsa-pcm.c @@ -1626,7 +1626,9 @@ static int handle_play(struct state *state, uint64_t nsec, int res; if (SPA_UNLIKELY(delay > target + state->max_error)) { - spa_log_trace(state->log, NAME" %p: early wakeup %ld %ld", state, delay, target); + spa_log_trace(state->log, NAME" %p: early wakeup %lu %lu", state, delay, target); + if (delay > target * 3) + delay = target * 3; state->next_time = nsec + (delay - target) * SPA_NSEC_PER_SEC / state->rate; return -EAGAIN; }