[vlc-devel] [PATCH] Added functions to get/set the media player audio delay.

Rémi Denis-Courmont remi at remlab.net
Sat Jul 10 20:05:42 CEST 2010


Comments inline.

Le samedi 10 juillet 2010 20:32:42 Mark Lee, vous avez écrit :
> ---
>  include/vlc/libvlc_media_player.h |   16 ++++++++++++++++
>  src/control/media_player.c        |   28 ++++++++++++++++++++++++++++
>  src/libvlc.sym                    |    2 ++
>  3 files changed, 46 insertions(+), 0 deletions(-)
> 
> diff --git a/include/vlc/libvlc_media_player.h
> b/include/vlc/libvlc_media_player.h index 33654a9..9b7bc18 100644
> --- a/include/vlc/libvlc_media_player.h
> +++ b/include/vlc/libvlc_media_player.h
> @@ -552,6 +552,22 @@ VLC_PUBLIC_API int libvlc_media_player_can_pause(
> libvlc_media_player_t *p_mi ); */
>  VLC_PUBLIC_API void libvlc_media_player_next_frame( libvlc_media_player_t
> *p_mi );
> 
> +/**
> + * Get current audio delay.
> + *
> + * \param p_mi media player
> + * \return the audio delay (microseconds)

You should probably add a \version Doxygen stanza.

> + */
> +VLC_PUBLIC_API int64_t libvlc_media_player_get_audio_delay(
> libvlc_media_player_t *p_mi );

I think this belongs in the Audio functions group rather than plain Media 
Player.

> +
> +/**
> + * Set current audio delay.
> + *
> + * \param p_mi media player
> + * \param i_delay the audio delay (microseconds)
> + * \return 0 on success, -1 on error
> + */
> +VLC_PUBLIC_API int libvlc_media_player_set_audio_delay(
> libvlc_media_player_t *p_mi, int64_t i_delay );

Same comments here.

>  /**
> diff --git a/src/control/media_player.c b/src/control/media_player.c
> index cf54fcd..bfe8ec3 100644
> --- a/src/control/media_player.c
> +++ b/src/control/media_player.c
> @@ -1288,3 +1288,31 @@ void libvlc_media_player_next_frame(
> libvlc_media_player_t *p_mi ) vlc_object_release( p_input_thread );
>      }
>  }
> +
> +int64_t libvlc_media_player_get_audio_delay( libvlc_media_player_t *p_mi )
> +{
> +    input_thread_t *p_input_thread = libvlc_get_input_thread ( p_mi );
> +    int64_t val = 0;
> +    if( p_input_thread != NULL )
> +    {
> +      val = var_GetTime( p_input_thread, "audio-delay" );
> +      vlc_object_release( p_input_thread );
> +    }
> +    return val;
> +}
> +
> +int libvlc_media_player_set_audio_delay( libvlc_media_player_t *p_mi,
> int64_t i_delay ) +{
> +    input_thread_t *p_input_thread = libvlc_get_input_thread ( p_mi );
> +    int ret = 0;
> +    if( p_input_thread != NULL )
> +    {
> +      var_SetTime( p_input_thread, "audio-delay", i_delay );
> +      vlc_object_release( p_input_thread );
> +    }
> +    else
> +    {
> +      ret = -1;
> +    }
> +    return ret;
> +}

At the very least, it should be noted in the documentation that the delay will 
be reset to zero at the next media item. Alternatively, the delay could be 
preserved with some extra hackery, but I am not sure if it makes much sense.

-- 
Rémi Denis-Courmont
http://www.remlab.net/
http://fi.linkedin.com/in/remidenis



More information about the vlc-devel mailing list