[vlc-commits] libvlc_clock, libvlc_delay: expose LibVLC clock for audio sync

Rémi Denis-Courmont git at videolan.org
Tue May 10 20:06:54 CEST 2011


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Tue May 10 21:05:57 2011 +0300| [dc7fff375fff04c99c7acc0195378bce5932a736] | committer: Rémi Denis-Courmont

libvlc_clock, libvlc_delay: expose LibVLC clock for audio sync

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=dc7fff375fff04c99c7acc0195378bce5932a736
---

 include/vlc/libvlc.h |   28 ++++++++++++++++++++++++++++
 src/control/core.c   |    5 +++++
 src/libvlc.sym       |    1 +
 3 files changed, 34 insertions(+), 0 deletions(-)

diff --git a/include/vlc/libvlc.h b/include/vlc/libvlc.h
index 9091ace..32bd683 100644
--- a/include/vlc/libvlc.h
+++ b/include/vlc/libvlc.h
@@ -448,6 +448,34 @@ LIBVLC_API
 libvlc_module_description_t *libvlc_video_filter_list_get( libvlc_instance_t *p_instance );
 
 /** @} */
+
+/** \defgroup libvlc_clock LibVLC time
+ * These functions provide access to the LibVLC time/clock.
+ * @{
+ */
+
+/**
+ * Return the current time as defined by LibVLC. The unit is the microsecond.
+ * Time increases monotonically (regardless of time zone changes and RTC
+ * adjustements).
+ * The origin is arbitrary but consistent across the whole system
+ * (e.g. the system uptim, the time since the system was booted).
+ * \note On systems that support it, the POSIX monotonic clock is used.
+ */
+LIBVLC_API
+int64_t libvlc_clock(void);
+
+/**
+ * Return the delay (in microseconds) until a certain timestamp.
+ * \param pts timestamp
+ * \return negative if timestamp is in the past,
+ * positive if it is in the future
+ */
+static inline int64_t libvlc_delay(int64_t pts)
+{
+    return pts - libvlc_clock();
+}
+
 /** @} */
 
 # ifdef __cplusplus
diff --git a/src/control/core.c b/src/control/core.c
index dfa0bb5..2fb4084 100644
--- a/src/control/core.c
+++ b/src/control/core.c
@@ -238,3 +238,8 @@ libvlc_module_description_t *libvlc_video_filter_list_get( libvlc_instance_t *p_
 {
     return libvlc_module_description_list_get( p_instance, "video filter2" );
 }
+
+int64_t libvlc_clock(void)
+{
+    return mdate();
+}
diff --git a/src/libvlc.sym b/src/libvlc.sym
index 235aa56..a370779 100644
--- a/src/libvlc.sym
+++ b/src/libvlc.sym
@@ -25,6 +25,7 @@ libvlc_audio_set_mute
 libvlc_audio_set_track
 libvlc_audio_set_volume
 libvlc_audio_toggle_mute
+libvlc_clock
 libvlc_event_attach
 libvlc_event_detach
 libvlc_event_manager_new



More information about the vlc-commits mailing list