[vlc-devel] [PATCH 02/15] vlc_common: add helper macros to convert to/from seconds/mtime_t explicitly

Steve Lhomme robux4 at ycbcr.xyz
Fri Jun 15 17:09:13 CEST 2018


---
 include/vlc_common.h | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/include/vlc_common.h b/include/vlc_common.h
index cc2f39e84a5..3d17d8e6a63 100644
--- a/include/vlc_common.h
+++ b/include/vlc_common.h
@@ -289,7 +289,10 @@
 typedef int64_t mtime_t;
 
 #define VTICK_FROM_MILLI(ms) ((ms) * (CLOCK_FREQ / 1000))
-#define MILLI_FROM_VTICK(ms) (((ms) * 1000) / CLOCK_FREQ)
+#define MILLI_FROM_VTICK(ms) ((ms) / (CLOCK_FREQ / 1000))
+
+#define SEC_FROM_VTICK(mt)  ((mt) / CLOCK_FREQ)      /* mtime_t in seconds */
+#define VTICK_FROM_SEC(sec) ((mtime_t)((sec) * CLOCK_FREQ)) /* seconds in mtime_t */
 
 
 /**
-- 
2.17.0



More information about the vlc-devel mailing list