From 8852154b4d7470d4de577120998fc2d3d5701bf0 Mon Sep 17 00:00:00 2001 From: Steve Gotthardt Date: Sat, 27 Dec 2008 20:56:54 +0000 Subject: 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 --- firmware/sound.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/firmware/sound.c b/firmware/sound.c index fb377f6..60ec1a4 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 -- cgit v1.1