[vlc-devel] [RFC PATCH 5/8] playlist: use vlc_renderer for audio volume/mute
Thomas Guillem
thomas at gllm.fr
Thu Feb 18 17:33:15 CET 2016
From: Steve Lhomme <robux4 at videolabs.io>
---
src/playlist/aout.c | 65 ++++++++++++++++++++++++++++++++---------------------
1 file changed, 39 insertions(+), 26 deletions(-)
diff --git a/src/playlist/aout.c b/src/playlist/aout.c
index d24e14f..fc10ffc 100644
--- a/src/playlist/aout.c
+++ b/src/playlist/aout.c
@@ -29,6 +29,7 @@
#include <vlc_common.h>
#include <vlc_aout.h>
#include <vlc_playlist.h>
+#include <vlc_renderer.h>
#include "../audio_output/aout_internal.h"
#include "playlist_internal.h"
@@ -47,25 +48,32 @@ float playlist_VolumeGet (playlist_t *pl)
{
float volume = -1.f;
- audio_output_t *aout = playlist_GetAout (pl);
- if (aout != NULL)
+ int ret = vlc_renderer_volume_get (pl, &volume);
+ if (ret == VLC_ENOOBJ)
{
- volume = aout_VolumeGet (aout);
- vlc_object_release (aout);
+ audio_output_t *aout = playlist_GetAout (pl);
+ if (aout != NULL)
+ {
+ volume = aout_VolumeGet (aout);
+ vlc_object_release (aout);
+ }
}
return volume;
}
int playlist_VolumeSet (playlist_t *pl, float vol)
{
- int ret = -1;
+ int ret = VLC_EGENERIC;
+ int rret = vlc_renderer_volume_set (pl, vol);
audio_output_t *aout = playlist_GetAout (pl);
if (aout != NULL)
{
ret = aout_VolumeSet (aout, vol);
vlc_object_release (aout);
}
+ if (rret == VLC_SUCCESS)
+ return VLC_SUCCESS;
return ret;
}
@@ -82,23 +90,18 @@ int playlist_VolumeUp (playlist_t *pl, int value, float *volp)
float delta = value * stepSize;
- audio_output_t *aout = playlist_GetAout (pl);
- if (aout != NULL)
+ float vol = playlist_VolumeGet( pl );
+ if (vol >= 0.f)
{
- float vol = aout_VolumeGet (aout);
- if (vol >= 0.f)
- {
- vol += delta;
- if (vol < 0.f)
- vol = 0.f;
- if (vol > 2.f)
- vol = 2.f;
- vol = (roundf (vol / stepSize)) * stepSize;
- if (volp != NULL)
- *volp = vol;
- ret = aout_VolumeSet (aout, vol);
- }
- vlc_object_release (aout);
+ vol += delta;
+ if (vol < 0.f)
+ vol = 0.f;
+ if (vol > 2.f)
+ vol = 2.f;
+ vol = (roundf (vol / stepSize)) * stepSize;
+ if (volp != NULL)
+ *volp = vol;
+ ret = playlist_VolumeSet (pl, vol);
}
return ret;
}
@@ -107,25 +110,35 @@ int playlist_MuteGet (playlist_t *pl)
{
int mute = -1;
- audio_output_t *aout = playlist_GetAout (pl);
- if (aout != NULL)
+ bool b_muted;
+ int ret = vlc_renderer_mute_get (pl, &b_muted);
+ if (ret == VLC_SUCCESS)
+ mute = b_muted;
+ else if (ret == VLC_ENOOBJ)
{
- mute = aout_MuteGet (aout);
- vlc_object_release (aout);
+ audio_output_t *aout = playlist_GetAout (pl);
+ if (aout != NULL)
+ {
+ mute = aout_MuteGet (aout);
+ vlc_object_release (aout);
+ }
}
return mute;
}
int playlist_MuteSet (playlist_t *pl, bool mute)
{
- int ret = -1;
+ int ret = VLC_EGENERIC;
+ int rret = vlc_renderer_mute_set (pl, mute);
audio_output_t *aout = playlist_GetAout (pl);
if (aout != NULL)
{
ret = aout_MuteSet (aout, mute);
vlc_object_release (aout);
}
+ if (rret == VLC_SUCCESS)
+ return VLC_SUCCESS;
return ret;
}
--
2.7.0
More information about the vlc-devel
mailing list