aboutsummaryrefslogtreecommitdiffstats
path: root/OpenAL32
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2010-12-01 02:24:39 -0800
committerChris Robinson <[email protected]>2010-12-01 02:24:39 -0800
commite3afc3587e204a089e460bb5f95a808895ba0256 (patch)
tree889f7e06e79b81386d424f0711fc34d246cbca62 /OpenAL32
parent8a52c44d15c88761971a5f826b4ac368ba8d1817 (diff)
Fix handling of -32768 in the muLaw encoder
Diffstat (limited to 'OpenAL32')
-rw-r--r--OpenAL32/alBuffer.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/OpenAL32/alBuffer.c b/OpenAL32/alBuffer.c
index 3cde5698..e85d2626 100644
--- a/OpenAL32/alBuffer.c
+++ b/OpenAL32/alBuffer.c
@@ -838,7 +838,13 @@ static ALmulaw EncodeMuLaw(ALshort val)
ALint mant, exp, sign;
sign = (val>>8) & 0x80;
- if(sign) val = (ALshort)-val;
+ if(sign)
+ {
+ /* -32768 doesn't properly negate on a short; it results in itself.
+ * So clamp to -32767 */
+ val = max(val, -32767);
+ val = -val;
+ }
val = min(val, muLawClip);
val += muLawBias;