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

LibVLC: fix volume scale and make documentation more explicit

parent cb96c1cd
......@@ -1403,18 +1403,19 @@ LIBVLC_API int libvlc_audio_get_mute( libvlc_media_player_t *p_mi );
LIBVLC_API void libvlc_audio_set_mute( libvlc_media_player_t *p_mi, int status );
/**
* Get current audio level.
* Get current software audio volume.
*
* \param p_mi media player
* \return the audio level (int)
* \return the software volume in percents
* (0 = mute, 100 = nominal / 0dB)
*/
LIBVLC_API int libvlc_audio_get_volume( libvlc_media_player_t *p_mi );
/**
* Set current audio level.
* Set current software audio volume.
*
* \param p_mi media player
* \param i_volume the volume (int)
* \param i_volume the volume in percents (0 = mute, 100 = 0dB)
* \return 0 if the volume was set, -1 if it was out of range
*/
LIBVLC_API int libvlc_audio_set_volume( libvlc_media_player_t *p_mi, int i_volume );
......
......@@ -327,29 +327,28 @@ void libvlc_audio_set_mute( libvlc_media_player_t *mp, int mute )
}
/*****************************************************************************
* libvlc_audio_get_volume : Get the current volume (range 0-200 %)
* libvlc_audio_get_volume : Get the current volume
*****************************************************************************/
int libvlc_audio_get_volume( libvlc_media_player_t *mp )
{
audio_volume_t i_volume = aout_VolumeGet( mp );
unsigned volume = aout_VolumeGet( mp );
return (i_volume*200+AOUT_VOLUME_MAX/2)/AOUT_VOLUME_MAX;
return (volume * 100 + AOUT_VOLUME_DEFAULT / 2) / AOUT_VOLUME_DEFAULT;
}
/*****************************************************************************
* libvlc_audio_set_volume : Set the current volume
*****************************************************************************/
int libvlc_audio_set_volume( libvlc_media_player_t *mp, int i_volume )
int libvlc_audio_set_volume( libvlc_media_player_t *mp, int volume )
{
if( i_volume < 0 || i_volume > 200 )
volume = (volume * AOUT_VOLUME_DEFAULT + 50) / 100;
if (volume < 0 || volume > AOUT_VOLUME_MAX)
{
libvlc_printerr( "Volume out of range" );
return -1;
}
i_volume = (i_volume * AOUT_VOLUME_MAX + 100) / 200;
aout_VolumeSet( mp, i_volume );
aout_VolumeSet (mp, volume);
return 0;
}
......
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