[vlc-devel] [PATCH] libvlc: return int for libvlc_MediaPlayerAudioVolume
Rémi Denis-Courmont
remi at remlab.net
Mon Oct 3 18:34:43 CEST 2016
Le maanantaina 3. lokakuuta 2016, 15.41.45 EEST Daniel Amm a écrit :
> Since libvlc_audio_get_volume() returns an integer (0=mute, 100=nominal),
> the associated event should also do that. So the API would be more
> consistent.
No, this breaks the ABI.
Besides, float is a much better suited representation here.
> ---
> include/vlc/libvlc_events.h | 2 +-
> lib/media_player.c | 3 ++-
> 2 files changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/include/vlc/libvlc_events.h b/include/vlc/libvlc_events.h
> index b69c5ce..d5fa80b 100644
> --- a/include/vlc/libvlc_events.h
> +++ b/include/vlc/libvlc_events.h
> @@ -267,7 +267,7 @@ typedef struct libvlc_event_t
>
> struct
> {
> - float volume;
> + int volume;
> } media_player_audio_volume;
>
> struct
> diff --git a/lib/media_player.c b/lib/media_player.c
> index 9a8f73a..2df3c48 100644
> --- a/lib/media_player.c
> +++ b/lib/media_player.c
> @@ -41,6 +41,7 @@
> #include "media_internal.h" // libvlc_media_set_state()
> #include "media_player_internal.h"
> #include "renderer_discoverer_internal.h"
> +#include <math.h> //lroundf()
>
> static int
> input_seekable_changed( vlc_object_t * p_this, char const * psz_cmd,
> @@ -567,7 +568,7 @@ static int volume_changed(vlc_object_t *obj, const char
> *name, vlc_value_t old, libvlc_event_t event;
>
> event.type = libvlc_MediaPlayerAudioVolume;
> - event.u.media_player_audio_volume.volume = cur.f_float;
> + event.u.media_player_audio_volume.volume = lroundf( cur.f_float * 100.f
> ); libvlc_event_send(mp->p_event_manager, &event);
> VLC_UNUSED(name); VLC_UNUSED(old); VLC_UNUSED(opaque);
> return VLC_SUCCESS;
--
Rémi Denis-Courmont
Nonsponsored VLC developer
http://www.remlab.net/CV.pdf
More information about the vlc-devel
mailing list