Skip to content

Commit

Permalink
Merge pull request #76 from lahwaacz/volume_fix
Browse files Browse the repository at this point in the history
Volume percentage should be obtained by float division and rounded to int
  • Loading branch information
stapelberg committed Oct 12, 2015
2 parents 1935110 + 611e863 commit dc94d6c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ CFLAGS+=-Iinclude
LIBS+=-lconfuse
LIBS+=-lyajl
LIBS+=-lpulse
LIBS+=-lm

VERSION:=$(shell git describe --tags --abbrev=0)
GIT_VERSION:="$(shell git describe --tags --always) ($(shell git log --pretty=format:%cd --date=short -n1))"
Expand Down
3 changes: 2 additions & 1 deletion src/pulse.c
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit dc94d6c

Please sign in to comment.