[vlc-commits] aout: add rounding to playlist_VolumeUp

Alex Peak git at videolan.org
Thu Mar 6 21:13:09 CET 2014


vlc | branch: master | Alex Peak <bobcatawareness at gmail.com> | Wed Mar  5 16:49:44 2014 -0800| [47b703a0a268fc855463b927814b720f61f264c7] | committer: Rémi Denis-Courmont

aout: add rounding to playlist_VolumeUp

Additional rounding step ensures that new volume is a multiple of the
"volume-step" as defined in libvlc-module.c.

Signed-off-by: Rémi Denis-Courmont <remi at remlab.net>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=47b703a0a268fc855463b927814b720f61f264c7
---

 src/playlist/aout.c |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/playlist/aout.c b/src/playlist/aout.c
index 05ed231..f00eaa2 100644
--- a/src/playlist/aout.c
+++ b/src/playlist/aout.c
@@ -24,6 +24,8 @@
 # include "config.h"
 #endif
 
+#include <math.h>
+
 #include <vlc_common.h>
 #include <vlc_aout.h>
 #include <vlc_playlist.h>
@@ -76,7 +78,9 @@ int playlist_VolumeUp (playlist_t *pl, int value, float *volp)
 {
     int ret = -1;
 
-    float delta = value * var_InheritFloat (pl, "volume-step");
+    float stepSize = var_InheritFloat (pl, "volume-step") / (float)AOUT_VOLUME_DEFAULT;
+
+    float delta = value * stepSize;
 
     audio_output_t *aout = playlist_GetAout (pl);
     if (aout != NULL)
@@ -84,11 +88,12 @@ int playlist_VolumeUp (playlist_t *pl, int value, float *volp)
         float vol = aout_VolumeGet (aout);
         if (vol >= 0.)
         {
-            vol += delta / (float)AOUT_VOLUME_DEFAULT;
+            vol += delta;
             if (vol < 0.)
                 vol = 0.;
             if (vol > 2.)
                 vol = 2.;
+            vol = (roundf (vol / stepSize)) * stepSize;
             if (volp != NULL)
                 *volp = vol;
             ret = aout_VolumeSet (aout, vol);



More information about the vlc-commits mailing list