From 9dae98071fb2f98ecac07ae33854f18ce3dbce11 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Mon, 20 May 2013 01:34:14 -0700 Subject: Fix possible overflow when converting float to int Same as with the mixer, we can only use 25 bits of precision from floats. --- OpenAL32/alBuffer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenAL32') diff --git a/OpenAL32/alBuffer.c b/OpenAL32/alBuffer.c index 41444ac2..af6e1ffc 100644 --- a/OpenAL32/alBuffer.c +++ b/OpenAL32/alBuffer.c @@ -1393,7 +1393,7 @@ static __inline ALint Conv_ALint_ALfloat(ALfloat val) { if(val > 1.0f) return 2147483647; if(val < -1.0f) return -2147483647-1; - return (ALint)(val * 2147483647.0); + return (ALint)(val*16777215.0f) << 7; } static __inline ALint Conv_ALint_ALdouble(ALdouble val) { @@ -1426,7 +1426,7 @@ static __inline ALuint Conv_ALuint_ALfloat(ALfloat val) { if(val > 1.0f) return 4294967295u; if(val < -1.0f) return 0; - return (ALint)(val * 2147483647.0) + 2147483648u; + return ((ALint)(val*16777215.0f)<<7) + 2147483648u; } static __inline ALuint Conv_ALuint_ALdouble(ALdouble val) { -- cgit v1.2.3