summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/dsp.c4
-rw-r--r--apps/replaygain.c8
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
39void replaygain_itoa(char* buffer, int length, long int_gain) 41void 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