From 8d8f75365288a6c3a6b97879f1ded606aa1b5bc0 Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Tue, 27 Jul 2010 16:54:44 +0000 Subject: [PATCH] corrected sound mixing for lower bound in addition to upper bound, but algorithm is still incorrect git-svn-id: svn://anubis/anaglym/trunk@298 99a6e188-d820-4881-8870-2d33a10e2619 --- AV.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AV.cc b/AV.cc index ba862c6..8c64f9f 100644 --- a/AV.cc +++ b/AV.cc @@ -187,8 +187,8 @@ void AV::playCallback(Uint8 * stream, int len) i < samples_decoded; i++) { - stream16[i] = - min(SHRT_MAX, stream16[i] + (int)(volume * m_sound_buffer[i])); + int sample_val = stream16[i] + (int)(volume * m_sound_buffer[i]); + stream16[i] = min(SHRT_MAX, max(SHRT_MIN, sample_val)); } } int sz = m_active_sounds.size();