[vlc-devel] [PATCH 03/10] vlc_tick: add helper functions to convert (milli)seconds to/from vlc_tick_t

Steve Lhomme robux4 at ycbcr.xyz
Fri Jun 22 14:53:20 CEST 2018


---
 include/vlc_tick.h | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/include/vlc_tick.h b/include/vlc_tick.h
index 246c7311b5c..66cf8ecf687 100644
--- a/include/vlc_tick.h
+++ b/include/vlc_tick.h
@@ -51,6 +51,28 @@ typedef vlc_tick_t mtime_t; /* deprecated, use vlc_tick_t */
 #define VLC_TICK_FROM_SEC(sec)   ((sec) * CLOCK_FREQ)   /* seconds in vlc_tick_t */
 #define SEC_FROM_VLC_TICK(vtk)   ((vtk) / CLOCK_FREQ)   /* vlc_tick_t in seconds */
 
+static inline vlc_tick_t vlc_tick_from_sec(int64_t sec)
+{
+    return sec * CLOCK_FREQ;
+}
+
+static inline int64_t sec_from_vlc_tick(vlc_tick_t vtk)
+{
+    return vtk / CLOCK_FREQ;
+}
+
+static inline vlc_tick_t vlc_tick_from_ms(int64_t ms)
+{
+    /* TODO refine if CLOCK_FREQ is not a multiple of 1000 */
+    return ms * (CLOCK_FREQ / 1000);
+}
+
+static inline int64_t ms_from_vlc_tick(vlc_tick_t vtk)
+{
+    /* TODO refine if CLOCK_FREQ is not a multiple of 1000 */
+    return vtk / (CLOCK_FREQ / 1000);
+}
+
 /*****************************************************************************
  * MSTRTIME_MAX_SIZE: maximum possible size of mstrtime
  *****************************************************************************
-- 
2.17.0



More information about the vlc-devel mailing list