[vlc-commits] Enforce volume min and max (small regression from previous commits)
Rémi Denis-Courmont
git at videolan.org
Thu Apr 7 22:41:32 CEST 2011
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Thu Apr 7 23:39:32 2011 +0300| [164c18c9233b160c9b36062e6a78b57f30591435] | committer: Rémi Denis-Courmont
Enforce volume min and max (small regression from previous commits)
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=164c18c9233b160c9b36062e6a78b57f30591435
---
src/audio_output/intf.c | 17 ++++++++++++-----
1 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/src/audio_output/intf.c b/src/audio_output/intf.c
index 776e11f..a4a77a9 100644
--- a/src/audio_output/intf.c
+++ b/src/audio_output/intf.c
@@ -76,10 +76,17 @@ static void prepareVolume (vlc_object_t *obj, aout_instance_t **aoutp,
/** Commit a volume change transaction. */
static int commitVolume (vlc_object_t *obj, aout_instance_t *aout,
- audio_volume_t volume, bool mute)
+ audio_volume_t *volp, bool mute)
{
int ret = 0;
+ audio_volume_t volume = *volp;
+ if (volume < AOUT_VOLUME_MIN)
+ volume = AOUT_VOLUME_MIN;
+ if (volume > AOUT_VOLUME_MAX)
+ volume = AOUT_VOLUME_MAX;
+ *volp = volume;
+
var_SetInteger (obj, "volume", volume);
var_SetBool (obj, "mute", mute);
@@ -142,7 +149,7 @@ int aout_VolumeSet (vlc_object_t *obj, audio_volume_t volume)
bool mute;
prepareVolume (obj, &aout, NULL, &mute);
- return commitVolume (obj, aout, volume, mute);
+ return commitVolume (obj, aout, &volume, mute);
}
#undef aout_VolumeUp
@@ -160,7 +167,7 @@ int aout_VolumeUp (vlc_object_t *obj, int steps, audio_volume_t *volp)
prepareVolume (obj, &aout, &volume, &mute);
volume += stepsize * steps;
- ret = commitVolume (obj, aout, volume, mute);
+ ret = commitVolume (obj, aout, &volume, mute);
if (volp != NULL)
*volp = volume;
return ret;
@@ -188,7 +195,7 @@ int aout_ToggleMute (vlc_object_t *obj, audio_volume_t *volp)
prepareVolume (obj, &aout, &volume, &mute);
mute = !mute;
- ret = commitVolume (obj, aout, volume, mute);
+ ret = commitVolume (obj, aout, &volume, mute);
if (volp != NULL)
*volp = mute ? AOUT_VOLUME_MIN : volume;
return ret;
@@ -221,7 +228,7 @@ int aout_SetMute (vlc_object_t *obj, audio_volume_t *volp, bool mute)
audio_volume_t volume;
prepareVolume (obj, &aout, &volume, NULL);
- ret = commitVolume (obj, aout, volume, mute);
+ ret = commitVolume (obj, aout, &volume, mute);
if (volp != NULL)
*volp = mute ? AOUT_VOLUME_MIN : volume;
return ret;
More information about the vlc-commits
mailing list