aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Micay <danielmicay@gmail.com>2014-08-20 17:49:23 -0400
committerDave Reisner <dreisner@archlinux.org>2014-08-20 18:11:35 -0400
commit850be03f11cd945604b62384fa7bd279bd378d89 (patch)
treeb06d6eed72c52d25f643b0089571e75cb18d0ae7
parent02762524f5a1d308f25812113a55770f0335c361 (diff)
downloadmirror-ponymix-850be03f11cd945604b62384fa7bd279bd378d89.tar.gz
mirror-ponymix-850be03f11cd945604b62384fa7bd279bd378d89.tar.bz2
mirror-ponymix-850be03f11cd945604b62384fa7bd279bd378d89.zip
fix volume rounding
Closes #26
-rw-r--r--pulse.cc4
1 files changed, 2 insertions, 2 deletions
diff --git a/pulse.cc b/pulse.cc
index 1253c2d..5bae79a 100644
--- a/pulse.cc
+++ b/pulse.cc
@@ -73,11 +73,11 @@ static void server_info_cb(pa_context* context __attribute__((unused)),
static pa_cvolume* value_to_cvol(long value, pa_cvolume *cvol) {
return pa_cvolume_set(cvol, cvol->channels,
- std::max((value + .5) * PA_VOLUME_NORM / 100, 0.0));
+ std::max(value * PA_VOLUME_NORM / 100.0, 0.0));
}
static int volume_as_percent(const pa_cvolume* cvol) {
- return pa_cvolume_avg(cvol) * 100.0 / PA_VOLUME_NORM;
+ return round(pa_cvolume_avg(cvol) * 100.0 / PA_VOLUME_NORM);
}
static int xstrtol(const char *str, long *out) {