From 8e6945c496876ab339ae76aef9d6e020b2a72b6c Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Tue, 9 Dec 2025 13:37:37 +0100 Subject: [PATCH] spa-resample: clamp float values sndfile does not seem to correctly clip samples so we have to do it ourselves. --- spa/plugins/audioconvert/spa-resample.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spa/plugins/audioconvert/spa-resample.c b/spa/plugins/audioconvert/spa-resample.c index 502b117e7..ec2c7b3cf 100644 --- a/spa/plugins/audioconvert/spa-resample.c +++ b/spa/plugins/audioconvert/spa-resample.c @@ -297,7 +297,7 @@ static int do_conversion(struct data *d) if (pout_len > 0) { for (k = 0, i = 0; i < pout_len; i++) { for (j = 0; j < channels; j++) { - obuf[k++] = out[MAX_SAMPLES * j + i]; + obuf[k++] = SPA_CLAMP(out[MAX_SAMPLES * j + i], -1.0f, 1.0f); } } pout_len = sf_writef_float(d->ofile, obuf, pout_len);