Commit e1eb563f authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

aout: move volume/mute code to output.c

parent 848f8d62
...@@ -136,6 +136,14 @@ void aout_volume_Delete(aout_volume_t *); ...@@ -136,6 +136,14 @@ void aout_volume_Delete(aout_volume_t *);
/* From output.c : */ /* From output.c : */
audio_output_t *aout_New (vlc_object_t *);
#define aout_New(a) aout_New(VLC_OBJECT(a))
void aout_Destroy (audio_output_t *);
float aout_OutputVolumeGet (audio_output_t *);
int aout_OutputVolumeSet (audio_output_t *, float);
int aout_OutputMuteGet (audio_output_t *);
int aout_OutputMuteSet (audio_output_t *, bool);
int aout_OutputNew( audio_output_t * p_aout, int aout_OutputNew( audio_output_t * p_aout,
const audio_sample_format_t * p_format ); const audio_sample_format_t * p_format );
void aout_OutputPlay( audio_output_t * p_aout, block_t * p_buffer ); void aout_OutputPlay( audio_output_t * p_aout, block_t * p_buffer );
...@@ -145,10 +153,6 @@ void aout_OutputDelete( audio_output_t * p_aout ); ...@@ -145,10 +153,6 @@ void aout_OutputDelete( audio_output_t * p_aout );
/* From common.c : */ /* From common.c : */
audio_output_t *aout_New (vlc_object_t *);
#define aout_New(a) aout_New(VLC_OBJECT(a))
void aout_Destroy (audio_output_t *);
void aout_FormatsPrint(vlc_object_t *, const char *, void aout_FormatsPrint(vlc_object_t *, const char *,
const audio_sample_format_t *, const audio_sample_format_t *,
const audio_sample_format_t *); const audio_sample_format_t *);
......
...@@ -72,7 +72,7 @@ float aout_VolumeGet (vlc_object_t *obj) ...@@ -72,7 +72,7 @@ float aout_VolumeGet (vlc_object_t *obj)
if (aout == NULL) if (aout == NULL)
return -1.f; return -1.f;
float volume = var_GetFloat (aout, "volume"); float volume = aout_OutputVolumeGet (aout);
vlc_object_release (aout); vlc_object_release (aout);
return volume; return volume;
} }
...@@ -89,10 +89,7 @@ int aout_VolumeSet (vlc_object_t *obj, float vol) ...@@ -89,10 +89,7 @@ int aout_VolumeSet (vlc_object_t *obj, float vol)
audio_output_t *aout = findAout (obj); audio_output_t *aout = findAout (obj);
if (aout != NULL) if (aout != NULL)
{ {
aout_lock (aout); ret = aout_OutputVolumeSet (aout, vol);
if (aout->volume_set != NULL)
ret = aout->volume_set (aout, vol);
aout_unlock (aout);
vlc_object_release (aout); vlc_object_release (aout);
} }
return ret; return ret;
...@@ -134,7 +131,7 @@ int aout_MuteGet (vlc_object_t *obj) ...@@ -134,7 +131,7 @@ int aout_MuteGet (vlc_object_t *obj)
if (aout == NULL) if (aout == NULL)
return -1.f; return -1.f;
bool mute = var_InheritBool (aout, "mute"); bool mute = aout_OutputMuteGet (aout);
vlc_object_release (aout); vlc_object_release (aout);
return mute; return mute;
} }
...@@ -150,15 +147,11 @@ int aout_MuteSet (vlc_object_t *obj, bool mute) ...@@ -150,15 +147,11 @@ int aout_MuteSet (vlc_object_t *obj, bool mute)
audio_output_t *aout = findAout (obj); audio_output_t *aout = findAout (obj);
if (aout != NULL) if (aout != NULL)
{ {
aout_lock (aout); ret = aout_OutputMuteSet (aout, mute);
if (aout->mute_set != NULL)
ret = aout->mute_set (aout, mute);
aout_unlock (aout);
vlc_object_release (aout); vlc_object_release (aout);
if (ret == 0)
var_SetBool (obj, "mute", mute);
} }
if (ret == 0)
var_SetBool (obj, "mute", mute);
return ret; return ret;
} }
......
...@@ -250,6 +250,56 @@ static void aout_Destructor (vlc_object_t *obj) ...@@ -250,6 +250,56 @@ static void aout_Destructor (vlc_object_t *obj)
vlc_mutex_destroy (&owner->lock); vlc_mutex_destroy (&owner->lock);
} }
/**
* Gets the volume of the audio output stream (independent of mute).
* \return Current audio volume (0. = silent, 1. = nominal),
* or a strictly negative value if undefined.
*/
float aout_OutputVolumeGet (audio_output_t *aout)
{
return var_GetFloat (aout, "volume");
}
/**
* Sets the volume of the audio output stream.
* \note The mute status is not changed.
* \return 0 on success, -1 on failure.
*/
int aout_OutputVolumeSet (audio_output_t *aout, float vol)
{
int ret = -1;
aout_lock (aout);
if (aout->volume_set != NULL)
ret = aout->volume_set (aout, vol);
aout_unlock (aout);
return ret;
}
/**
* Gets the audio output stream mute flag.
* \return 0 if not muted, 1 if muted, -1 if undefined.
*/
int aout_OutputMuteGet (audio_output_t *aout)
{
return var_InheritBool (aout, "mute");
}
/**
* Sets the audio output stream mute flag.
* \return 0 on success, -1 on failure.
*/
int aout_OutputMuteSet (audio_output_t *aout, bool mute)
{
int ret = -1;
aout_lock (aout);
if (aout->mute_set != NULL)
ret = aout->mute_set (aout, mute);
aout_unlock (aout);
return ret;
}
/** /**
* Starts an audio output stream. * Starts an audio output stream.
* \param fmtp audio output stream format [IN/OUT] * \param fmtp audio output stream format [IN/OUT]
......
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