[vlc-commits] LibVLC: fix volume scale and make documentation more explicit
Rémi Denis-Courmont
git at videolan.org
Tue Jul 26 17:41:54 CEST 2011
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Tue Jul 26 18:28:47 2011 +0300| [842a97aab3b0ecd04781d5805bd6a3f52b37bc76] | committer: Rémi Denis-Courmont
LibVLC: fix volume scale and make documentation more explicit
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=842a97aab3b0ecd04781d5805bd6a3f52b37bc76
---
include/vlc/libvlc_media_player.h | 9 +++++----
src/control/audio.c | 15 +++++++--------
2 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/include/vlc/libvlc_media_player.h b/include/vlc/libvlc_media_player.h
index d8c5519..0f24e37 100644
--- a/include/vlc/libvlc_media_player.h
+++ b/include/vlc/libvlc_media_player.h
@@ -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 );
diff --git a/src/control/audio.c b/src/control/audio.c
index 374dc27..aa71969 100644
--- a/src/control/audio.c
+++ b/src/control/audio.c
@@ -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;
}
More information about the vlc-commits
mailing list