[vlc-devel] [PATCH] Add functions to get/set audio delay.

Mark Lee mark.lee at capricasoftware.co.uk
Sun Jul 11 07:47:58 CEST 2010


Two new functions added:

 * val = libvlc_audio_get_delay( p_mi )
 * libvlc_audio_set_delay( p_mi, i_delay )

The delay is measured in microseconds.
---
 include/vlc/libvlc_media_player.h |   19 +++++++++++++++++++
 src/control/audio.c               |   34 ++++++++++++++++++++++++++++++++++
 src/libvlc.sym                    |    2 ++
 3 files changed, 55 insertions(+), 0 deletions(-)

diff --git a/include/vlc/libvlc_media_player.h b/include/vlc/libvlc_media_player.h
index 33654a9..f593599 100644
--- a/include/vlc/libvlc_media_player.h
+++ b/include/vlc/libvlc_media_player.h
@@ -1259,6 +1259,25 @@ VLC_PUBLIC_API int libvlc_audio_get_channel( libvlc_media_player_t *p_mi );
  */
 VLC_PUBLIC_API int libvlc_audio_set_channel( libvlc_media_player_t *p_mi, int channel );
 
+/**
+ * Get current audio delay.
+ *
+ * \param p_mi media player
+ * \return the audio delay (microseconds)
+ * \version LibVLC 1.1.1 or later
+ */
+VLC_PUBLIC_API int64_t libvlc_audio_get_delay( libvlc_media_player_t *p_mi );
+
+/**
+ * Set current audio delay. The audio delay will be reset to zero each time the media changes.
+ *
+ * \param p_mi media player
+ * \param i_delay the audio delay (microseconds)
+ * \return 0 on success, -1 on error
+ * \version LibVLC 1.1.1 or later
+ */
+VLC_PUBLIC_API int libvlc_audio_set_delay( libvlc_media_player_t *p_mi, int64_t i_delay );
+
 /** @} audio */
 
 /** @} media_player */
diff --git a/src/control/audio.c b/src/control/audio.c
index 2c5ed8a..b7ebf34 100644
--- a/src/control/audio.c
+++ b/src/control/audio.c
@@ -478,3 +478,37 @@ int libvlc_audio_set_channel( libvlc_media_player_t *mp, int channel )
     vlc_object_release( p_aout );
     return ret;
 }
+
+/*****************************************************************************
+ * libvlc_audio_get_delay : Get the current audio delay
+ *****************************************************************************/
+int64_t libvlc_audio_get_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;
+}
+
+/*****************************************************************************
+ * libvlc_audio_set_delay : Set the current audio delay
+ *****************************************************************************/
+int libvlc_audio_set_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;
+}
diff --git a/src/libvlc.sym b/src/libvlc.sym
index f05d463..afaf901 100644
--- a/src/libvlc.sym
+++ b/src/libvlc.sym
@@ -13,12 +13,14 @@ libvlc_audio_output_list_release
 libvlc_audio_output_set
 libvlc_audio_output_set_device_type
 libvlc_audio_get_channel
+libvlc_audio_get_delay
 libvlc_audio_get_mute
 libvlc_audio_get_track
 libvlc_audio_get_track_count
 libvlc_audio_get_track_description
 libvlc_audio_get_volume
 libvlc_audio_set_channel
+libvlc_audio_set_delay
 libvlc_audio_set_mute
 libvlc_audio_set_track
 libvlc_audio_set_volume
-- 
1.7.0.4




More information about the vlc-devel mailing list