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

Mark Lee mark.lee at capricasoftware.co.uk
Sat Jul 10 19:32:42 CEST 2010


---
 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)
+ */
+VLC_PUBLIC_API int64_t libvlc_media_player_get_audio_delay( libvlc_media_player_t *p_mi );
+
+/**
+ * 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 );
 
 
 /**
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;
+}
diff --git a/src/libvlc.sym b/src/libvlc.sym
index f05d463..07938f3 100644
--- a/src/libvlc.sym
+++ b/src/libvlc.sym
@@ -108,6 +108,7 @@ libvlc_media_player_can_pause
 libvlc_media_player_next_frame
 libvlc_media_player_event_manager
 libvlc_media_player_get_agl
+libvlc_media_player_get_audio_delay
 libvlc_media_player_get_chapter
 libvlc_media_player_get_chapter_count
 libvlc_media_player_get_chapter_count_for_title
@@ -136,6 +137,7 @@ libvlc_media_player_previous_chapter
 libvlc_media_player_release
 libvlc_media_player_retain
 libvlc_media_player_set_agl
+libvlc_media_player_set_audio_delay
 libvlc_media_player_set_chapter
 libvlc_media_player_set_hwnd
 libvlc_media_player_set_media
-- 
1.7.0.4




More information about the vlc-devel mailing list