From b62fc061e4833b12286a5f9b2e78894b614ce3fb Mon Sep 17 00:00:00 2001 From: Katsuhiro Suzuki Date: Fri, 29 Apr 2022 01:17:27 +0900 Subject: [PATCH] pcm: dmix: fix wrong scaling in 32bits pcm mixing Generic mixing function for 32bits pcm has used 8bits right shift for pre-scaling. But this is generating wrong result if pcm data is negative value because return value type of bswap_32() is unsigned int. This patch adds type cast bswap_32() result to signed int. Fixes: https://github.com/alsa-project/alsa-lib/pull/222 Signed-off-by: Katsuhiro Suzuki Signed-off-by: Jaroslav Kysela --- src/pcm/pcm_dmix_generic.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pcm/pcm_dmix_generic.c b/src/pcm/pcm_dmix_generic.c index 8a5b6f14..701c66c9 100644 --- a/src/pcm/pcm_dmix_generic.c +++ b/src/pcm/pcm_dmix_generic.c @@ -330,7 +330,7 @@ static void generic_mix_areas_32_swap(unsigned int size, register signed int sample; for (;;) { - sample = bswap_32(*src) >> 8; + sample = (signed int) bswap_32(*src) >> 8; if (! *dst) { *sum = sample; *dst = *src; @@ -364,7 +364,7 @@ static void generic_remix_areas_32_swap(unsigned int size, register signed int sample; for (;;) { - sample = bswap_32(*src) >> 8; + sample = (signed int) bswap_32(*src) >> 8; if (! *dst) { *sum = -sample; *dst = bswap_32(-sample); -- 2.47.1