From bfafd3ebbb1e1d736b4c922d0f59a117359d4eba Mon Sep 17 00:00:00 2001 From: John Stumpo Date: Wed, 9 Jan 2013 13:46:12 -0500 Subject: [PATCH] MixStream: properly clamp samples that clip --- src/MixStream/MixStream.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/MixStream/MixStream.c b/src/MixStream/MixStream.c index 067e80e24..3391601a1 100644 --- a/src/MixStream/MixStream.c +++ b/src/MixStream/MixStream.c @@ -228,6 +228,7 @@ static gboolean _mix_stream_nextchunk(MixStream* stream, gsize size) /* If we're converting stereo to mono, average this sample with the other channel's. */ if (stream->channels == 2 && stream->out_channels == 1) current_sample = (float)(0.5 * (current_sample + *(floatbuf++))); + current_sample = CLAMP(current_sample, -1.0, 1.0); #define OUTPUT_SAMPLE(type, value) { *(type*)out_buf = (type)(value); out_buf += sizeof(type); size -= sizeof(type); }