diff options
author | Chris Robinson <[email protected]> | 2013-05-20 01:34:14 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2013-05-20 01:34:14 -0700 |
commit | 9dae98071fb2f98ecac07ae33854f18ce3dbce11 (patch) | |
tree | fe0cc431782b319503a6fdef9d49e9ec5b582d5b /OpenAL32 | |
parent | 4c436b106d1a2b57e28fcaff0d5ec4a7abc6badc (diff) |
Fix possible overflow when converting float to int
Same as with the mixer, we can only use 25 bits of precision from
floats.
Diffstat (limited to 'OpenAL32')
-rw-r--r-- | OpenAL32/alBuffer.c | 4 |
1 files changed, 2 insertions, 2 deletions
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) { |