diff options
author | Michael Stapelberg <stapelberg@users.noreply.github.com> | 2015-10-12 11:29:52 -0700 |
---|---|---|
committer | Michael Stapelberg <stapelberg@users.noreply.github.com> | 2015-10-12 11:29:52 -0700 |
commit | dc94d6cba8112fa908eaf6de5354a17670f62545 (patch) | |
tree | d2461fb6d513fb281347297a39599bef6fc72c10 /src/pulse.c | |
parent | 1935110ef3c93072f49e5bfc8ee225206453415f (diff) | |
parent | 611e863ace93c18a71697bb9a3f8ffa18f03da6d (diff) |
Merge pull request #76 from lahwaacz/volume_fix
Volume percentage should be obtained by float division and rounded to int
Diffstat (limited to 'src/pulse.c')
-rw-r--r-- | src/pulse.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/pulse.c b/src/pulse.c index 5a381a0..34e302b 100644 --- a/src/pulse.c +++ b/src/pulse.c @@ -1,6 +1,7 @@ // vim:ts=4:sw=4:expandtab #include <string.h> #include <stdio.h> +#include <math.h> #include <pulse/pulseaudio.h> #include "i3status.h" #include "queue.h" @@ -78,7 +79,7 @@ static void store_volume_from_sink_cb(pa_context *c, return; int avg_vol = pa_cvolume_avg(&info->volume); - int vol_perc = (int)((long long)avg_vol * 100 / PA_VOLUME_NORM); + int vol_perc = roundf((float)avg_vol * 100 / PA_VOLUME_NORM); int composed_volume = COMPOSE_VOLUME_MUTE(vol_perc, info->mute); /* if this is the default sink we must try to save it twice: once with |