summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
authorSteve Gotthardt <gotthardt@rockbox.org>2008-12-27 20:56:54 +0000
committerSteve Gotthardt <gotthardt@rockbox.org>2008-12-27 20:56:54 +0000
commit8852154b4d7470d4de577120998fc2d3d5701bf0 (patch)
treec762de949caa544aee44d2afcf50fd04fcf70e8b /firmware
parent1fea6f6b22af74e904d918fff4cebec345529f4b (diff)
Fix for FS#9444. Scales balance between current and mute. Mutes channel at 100% balance when volume is muted.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19601 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
-rw-r--r--firmware/sound.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/firmware/sound.c b/firmware/sound.c
index fb377f6f6d..60ec1a405b 100644
--- a/firmware/sound.c
+++ b/firmware/sound.c
@@ -41,6 +41,8 @@
* find a nice way to handle 1.5db steps -> see wm8751 ifdef in sound_set_bass/treble
*/
+#define ONE_DB 10
+
#if !defined(VOLUME_MIN) && !defined(VOLUME_MAX)
#warning define for VOLUME_MIN and VOLUME_MAX is missing
#define VOLUME_MIN -700
@@ -283,17 +285,15 @@ static void set_prescaled_volume(void)
l = r = current_volume + prescale;
+ /* Balance the channels scaled by the current volume and min volume. */
+ /* Subtract a dB from VOLUME_MIN to get it to a mute level */
if (current_balance > 0)
{
- l -= current_balance;
- if (l < VOLUME_MIN)
- l = VOLUME_MIN;
+ l -= ((l - (VOLUME_MIN - ONE_DB)) * current_balance) / VOLUME_RANGE;
}
- if (current_balance < 0)
+ else if (current_balance < 0)
{
- r += current_balance;
- if (r < VOLUME_MIN)
- r = VOLUME_MIN;
+ r += ((r - (VOLUME_MIN - ONE_DB)) * current_balance) / VOLUME_RANGE;
}
#if CONFIG_CODEC == MAS3507D