summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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;