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.tar.gz rockbox-29164ccbccc83a7e5ec335acf5c37fde21649386.zip |
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
diff --git a/apps/dsp.c b/apps/dsp.c index 5910504122..3aab2f2df5 100644 --- a/apps/dsp.c +++ b/apps/dsp.c | |||
@@ -1475,12 +1475,12 @@ intptr_t dsp_configure(struct dsp_config *dsp, int setting, intptr_t value) | |||
1475 | 1475 | ||
1476 | case DSP_SET_TRACK_GAIN: | 1476 | case DSP_SET_TRACK_GAIN: |
1477 | if (dsp == &AUDIO_DSP) | 1477 | if (dsp == &AUDIO_DSP) |
1478 | dsp_set_gain_var(&track_gain, convert_gain(value)); | 1478 | dsp_set_gain_var(&track_gain, value ? convert_gain(value) : 0); |
1479 | break; | 1479 | break; |
1480 | 1480 | ||
1481 | case DSP_SET_ALBUM_GAIN: | 1481 | case DSP_SET_ALBUM_GAIN: |
1482 | if (dsp == &AUDIO_DSP) | 1482 | if (dsp == &AUDIO_DSP) |
1483 | dsp_set_gain_var(&album_gain, convert_gain(value)); | 1483 | dsp_set_gain_var(&album_gain, value ? convert_gain(value) : 0); |
1484 | break; | 1484 | break; |
1485 | 1485 | ||
1486 | case DSP_SET_TRACK_PEAK: | 1486 | case DSP_SET_TRACK_PEAK: |
diff --git a/apps/replaygain.c b/apps/replaygain.c index 3b47974d58..02be033657 100644 --- a/apps/replaygain.c +++ b/apps/replaygain.c | |||
@@ -35,6 +35,8 @@ | |||
35 | 35 | ||
36 | #define FP_BITS (12) | 36 | #define FP_BITS (12) |
37 | #define FP_ONE (1 << FP_BITS) | 37 | #define FP_ONE (1 << FP_BITS) |
38 | #define FP_MIN (-48 * FP_ONE) | ||
39 | #define FP_MAX ( 17 * FP_ONE) | ||
38 | 40 | ||
39 | void replaygain_itoa(char* buffer, int length, long int_gain) | 41 | void replaygain_itoa(char* buffer, int length, long int_gain) |
40 | { | 42 | { |
@@ -121,10 +123,10 @@ long convert_gain(long gain) | |||
121 | /* Don't allow unreasonably low or high gain changes. | 123 | /* Don't allow unreasonably low or high gain changes. |
122 | * Our math code can't handle it properly anyway. :) | 124 | * Our math code can't handle it properly anyway. :) |
123 | */ | 125 | */ |
124 | gain = MAX(gain,-48 * FP_ONE); | 126 | gain = MAX(gain, FP_MIN); |
125 | gain = MIN(gain, 17 * FP_ONE); | 127 | gain = MIN(gain, FP_MAX); |
126 | 128 | ||
127 | return (gain) ? fp_factor(gain, FP_BITS) << (24 - FP_BITS) : 0; | 129 | return fp_factor(gain, FP_BITS) << (24 - FP_BITS); |
128 | } | 130 | } |
129 | 131 | ||
130 | /* Get the sample scale factor in Q19.12 format from a gain value. Returns 0 | 132 | /* Get the sample scale factor in Q19.12 format from a gain value. Returns 0 |