From 92e6bcbe17d56d9acb50c52edc8f55233156ae8f Mon Sep 17 00:00:00 2001 From: Thom Johansen Date: Tue, 27 Feb 2007 17:55:38 +0000 Subject: Fix old bug where applying a crossfeed direct gain of 0 dB would result in negative gain. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12508 a1c6a512-1295-4272-9138-f99709370657 --- apps/dsp.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/apps/dsp.c b/apps/dsp.c index cca94ae..70f1ff4 100644 --- a/apps/dsp.c +++ b/apps/dsp.c @@ -769,6 +769,9 @@ void dsp_set_crossfeed(bool enable) void dsp_set_crossfeed_direct_gain(int gain) { crossfeed_data.gain = get_replaygain_int(gain * -10) << 7; + /* If gain is negative, the calculation overflowed and we need to clamp */ + if (crossfeed_data.gain < 0) + crossfeed_data.gain = 0x7fffffff; } void dsp_set_crossfeed_cross_params(long lf_gain, long hf_gain, long cutoff) -- cgit v1.1