Commit 0c788078 authored by Thomas Guillem's avatar Thomas Guillem

aout: move playlist_VolumeUp implementation to aout_VolumeUpdate

parent 0154e248
......@@ -290,8 +290,12 @@ VLC_API void aout_FormatPrint(vlc_object_t *, const char *,
#define aout_FormatPrint(o, t, f) aout_FormatPrint(VLC_OBJECT(o), t, f)
VLC_API const char * aout_FormatPrintChannels( const audio_sample_format_t * ) VLC_USED;
#define AOUT_VOLUME_DEFAULT 256
#define AOUT_VOLUME_MAX 512
VLC_API float aout_VolumeGet (audio_output_t *);
VLC_API int aout_VolumeSet (audio_output_t *, float);
VLC_API int aout_VolumeUpdate (audio_output_t *, int, float *);
VLC_API int aout_MuteGet (audio_output_t *);
VLC_API int aout_MuteSet (audio_output_t *, bool);
VLC_API char *aout_DeviceGet (audio_output_t *);
......
......@@ -29,6 +29,7 @@ extern "C" {
# endif
#include <vlc_events.h>
#include <vlc_aout.h>
TYPEDEF_ARRAY(playlist_item_t*, playlist_item_array_t)
......@@ -392,9 +393,6 @@ VLC_API void playlist_NodeDelete( playlist_t *, playlist_item_t * );
VLC_API audio_output_t *playlist_GetAout( playlist_t * );
#define AOUT_VOLUME_DEFAULT 256
#define AOUT_VOLUME_MAX 512
VLC_API float playlist_VolumeGet( playlist_t * );
VLC_API int playlist_VolumeSet( playlist_t *, float );
VLC_API int playlist_VolumeUp( playlist_t *, int, float * );
......
......@@ -738,6 +738,33 @@ int aout_VolumeSet (audio_output_t *aout, float vol)
return 0;
}
/**
* Raises the volume.
* \param value how much to increase (> 0) or decrease (< 0) the volume
* \param volp if non-NULL, will contain contain the resulting volume
*/
int aout_VolumeUpdate (audio_output_t *aout, int value, float *volp)
{
int ret = -1;
float stepSize = var_InheritFloat (aout, "volume-step") / (float)AOUT_VOLUME_DEFAULT;
float delta = value * stepSize;
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);
}
return ret;
}
/**
* Gets the audio output stream mute flag.
* \return 0 if not muted, 1 if muted, -1 if undefined.
......
......@@ -17,6 +17,7 @@ aout_FormatPrint
aout_FormatPrintChannels
aout_VolumeGet
aout_VolumeSet
aout_VolumeUpdate
aout_MuteSet
aout_MuteGet
aout_DeviceGet
......
......@@ -78,26 +78,10 @@ int playlist_VolumeUp (playlist_t *pl, int value, float *volp)
{
int ret = -1;
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)
{
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);
}
ret = aout_VolumeUpdate (aout, value, volp);
vlc_object_release (aout);
}
return ret;
......
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