From: Nikolas Garofil Date: Fri, 12 Feb 2010 17:57:02 +0000 (+0100) Subject: Fix wrong mixer values on some systems (thanks hoffa) X-Git-Url: https://vcs.maemo.org/git/?a=commitdiff_plain;h=29ef435c8fb559db0fe0e171dce4bef2e245fb06;p=monky Fix wrong mixer values on some systems (thanks hoffa) --- diff --git a/src/mixer.c b/src/mixer.c index 109ce9b..2b21ff2 100644 --- a/src/mixer.c +++ b/src/mixer.c @@ -177,11 +177,16 @@ int mixer_init (const char *name) } static int mixer_get_avg (int i) { - long val; + long val; - snd_mixer_handle_events (data.mixer); - snd_mixer_selem_get_playback_volume (data.elem, 0, &val); - return (int) val; + snd_mixer_handle_events (data.mixer); + snd_mixer_selem_get_playback_volume (data.elem, 0, &val); + if(data.vol_max != 100) { + float avgf = ((float)val / data.vol_max) * 100; + int avg = (int)avgf; + return (avgf - avg < 0.5) ? avg : avg + 1; + } + return (int) val; } static int mixer_get_left (int i) {