summaryrefslogtreecommitdiffstats
path: root/audio
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2016-07-14 18:11:14 +0200
committerwm4 <wm4@nowhere>2016-07-14 18:11:14 +0200
commitd191d76e52a992840ab614f760f1189391a5507d (patch)
tree4f9fd9687eaa65b3156bedf0aefd98f52feed567 /audio
parentf53d73b9dc373a41ab535b247f6a2178783b2b82 (diff)
downloadmpv-d191d76e52a992840ab614f760f1189391a5507d.tar.bz2
mpv-d191d76e52a992840ab614f760f1189391a5507d.tar.xz
ao_pulse: fix some volume control rounding issues
Volume could get easily "stuck" or making too huge steps when doing things like "add ao-volume 1".
Diffstat (limited to 'audio')
-rw-r--r--audio/out/ao_pulse.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/audio/out/ao_pulse.c b/audio/out/ao_pulse.c
index d553b6700c..fc0dd0d008 100644
--- a/audio/out/ao_pulse.c
+++ b/audio/out/ao_pulse.c
@@ -23,6 +23,7 @@
#include <stdbool.h>
#include <string.h>
#include <stdint.h>
+#include <math.h>
#include <pthread.h>
#include <pulse/pulseaudio.h>
@@ -34,8 +35,8 @@
#include "ao.h"
#include "internal.h"
-#define VOL_PA2MP(v) ((v) * 100 / PA_VOLUME_NORM)
-#define VOL_MP2PA(v) ((v) * PA_VOLUME_NORM / 100)
+#define VOL_PA2MP(v) ((v) * 100.0 / PA_VOLUME_NORM)
+#define VOL_MP2PA(v) lrint((v) * PA_VOLUME_NORM / 100)
struct priv {
// PulseAudio playback stream object