diff options
| author | Andree Buschmann <AndreeBuschmann@t-online.de> | 2011-03-31 21:46:09 +0000 |
|---|---|---|
| committer | Andree Buschmann <AndreeBuschmann@t-online.de> | 2011-03-31 21:46:09 +0000 |
| commit | 29164ccbccc83a7e5ec335acf5c37fde21649386 (patch) | |
| tree | dd90c9fc01e40fba1d29b3e22a95a75ec3a75254 /apps | |
| parent | 4f7930b883d32cbb8af69a293c96e8bff3ccd916 (diff) | |
| download | rockbox-29164ccbccc83a7e5ec335acf5c37fde21649386.zip rockbox-29164ccbccc83a7e5ec335acf5c37fde21649386.tar.gz rockbox-29164ccbccc83a7e5ec335acf5c37fde21649386.tar.bz2 rockbox-29164ccbccc83a7e5ec335acf5c37fde21649386.tar.xz | |
Changing convert_gain() also implicitly changed get_replaygain_int() which could lead to div by zero. This patch finds another way to fix the replaygain fallback.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29665 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
| -rw-r--r-- | apps/dsp.c | 4 | ||||
| -rw-r--r-- | apps/replaygain.c | 8 |
2 files changed, 7 insertions, 5 deletions
@@ -1475,12 +1475,12 @@ intptr_t dsp_configure(struct dsp_config *dsp, int setting, intptr_t value) case DSP_SET_TRACK_GAIN: if (dsp == &AUDIO_DSP) - dsp_set_gain_var(&track_gain, convert_gain(value)); + dsp_set_gain_var(&track_gain, value ? convert_gain(value) : 0); break; case DSP_SET_ALBUM_GAIN: if (dsp == &AUDIO_DSP) - dsp_set_gain_var(&album_gain, convert_gain(value)); + dsp_set_gain_var(&album_gain, value ? convert_gain(value) : 0); break; case DSP_SET_TRACK_PEAK: diff --git a/apps/replaygain.c b/apps/replaygain.c index 3b47974..02be033 100644 --- a/apps/replaygain.c +++ b/apps/replaygain.c @@ -35,6 +35,8 @@ #define FP_BITS (12) #define FP_ONE (1 << FP_BITS) +#define FP_MIN (-48 * FP_ONE) +#define FP_MAX ( 17 * FP_ONE) void replaygain_itoa(char* buffer, int length, long int_gain) { @@ -121,10 +123,10 @@ long convert_gain(long gain) /* Don't allow unreasonably low or high gain changes. * Our math code can't handle it properly anyway. :) */ - gain = MAX(gain,-48 * FP_ONE); - gain = MIN(gain, 17 * FP_ONE); + gain = MAX(gain, FP_MIN); + gain = MIN(gain, FP_MAX); - return (gain) ? fp_factor(gain, FP_BITS) << (24 - FP_BITS) : 0; + return fp_factor(gain, FP_BITS) << (24 - FP_BITS); } /* Get the sample scale factor in Q19.12 format from a gain value. Returns 0 |