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 <katsuhiro@katsuster.net>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
Katsuhiro Suzuki 2022-04-29 01:17:27 +09:00 committed by Jaroslav Kysela
parent a513e65e19
commit b62fc061e4

View file

@ -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);