Commit 47b703a0 authored by Alex Peak's avatar Alex Peak Committed by 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: default avatarRémi Denis-Courmont <remi@remlab.net>
parent e1078e06
......@@ -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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment