From 159fa7177a07fe8d23fb4c247380685d893a3ac1 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Wed, 5 Jul 2023 12:01:08 +0200 Subject: [PATCH] alsa: fix threshold sign Be careful when converting the uint32_t to int64_t, first convert and then flip the sign. --- 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 d2041ac50..b2338fcc1 100644 --- a/spa/plugins/alsa/alsa-pcm.c +++ b/spa/plugins/alsa/alsa-pcm.c @@ -2016,7 +2016,7 @@ static int get_avail(struct state *state, uint64_t current_time, snd_pcm_uframes spa_log_trace_fp(state->log, "%"PRIu64" %"PRIu64" %"PRIi64, current_time, then, diff); if (SPA_ABS(diff) < state->threshold * 3) { - *delay += SPA_CLAMP(diff, -state->threshold, state->threshold); + *delay += SPA_CLAMP(diff, -((int64_t)state->threshold), (int64_t)state->threshold); state->htimestamp_error = 0; } else { if (++state->htimestamp_error > MAX_HTIMESTAMP_ERROR) {