From 90e2f4a1392985104cbeec66373cc60d1ee13044 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Mon, 5 Jun 2023 16:49:02 +0200 Subject: [PATCH] alsa: fix impossible timeouts Use the avail and read_size to calculate the next timeout, not delay and target, which could give a negative value and impossible timeout. --- spa/plugins/alsa/alsa-pcm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spa/plugins/alsa/alsa-pcm.c b/spa/plugins/alsa/alsa-pcm.c index e63d4249a..8accddcf3 100644 --- a/spa/plugins/alsa/alsa-pcm.c +++ b/spa/plugins/alsa/alsa-pcm.c @@ -2509,7 +2509,7 @@ static int handle_capture(struct state *state, uint64_t current_time, snd_pcm_uf if (SPA_UNLIKELY(avail < state->read_size)) { spa_log_trace(state->log, "%p: early wakeup %ld %ld %ld %d", state, delay, avail, target, state->read_size); - state->next_time = current_time + (target - delay) * SPA_NSEC_PER_SEC / + state->next_time = current_time + (state->read_size - avail) * SPA_NSEC_PER_SEC / state->rate; return -EAGAIN; }