Commit 578c7b2c authored by Juha Riihim?ki's avatar Juha Riihim?ki Committed by malc

audio: fix integer overflow expression

Fix an integer overflow that can happen for signed 32 bit types
when using FLOAT_MIXENG. (Note that at the moment this is only true
when using the MacOSX coreaudio audio driver.)
Signed-off-by: default avatarJuha Riihim?ki <>
[Peter Maydell: Removed unnecessary casts]
Signed-off-by: default avatarPeter Maydell <>
Signed-off-by: default avatarmalc <>
parent b1d7d2b9
......@@ -46,7 +46,7 @@ static mixeng_real inline glue (conv_, ET) (IN_T v)
#else /* !RECIPROCAL */
#ifdef SIGNED
return nv / (mixeng_real) (IN_MAX - IN_MIN);
return nv / (mixeng_real) ((mixeng_real) IN_MAX - IN_MIN);
return (nv - HALF) / (mixeng_real) IN_MAX;
......@@ -63,7 +63,7 @@ static IN_T inline glue (clip_, ET) (mixeng_real v)
#ifdef SIGNED
return ENDIAN_CONVERT ((IN_T) (v * (IN_MAX - IN_MIN)));
return ENDIAN_CONVERT ((IN_T) (v * ((mixeng_real) IN_MAX - IN_MIN)));
return ENDIAN_CONVERT ((IN_T) ((v * IN_MAX) + HALF));
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment