aboutsummaryrefslogtreecommitdiffstats
path: root/libavutil/timer.h
diff options
context:
space:
mode:
authorZhao Zhili <zhilizhao@tencent.com>2024-06-07 21:44:50 +0800
committerZhao Zhili <zhilizhao@tencent.com>2024-06-11 01:11:36 +0800
commit33e4cc963d5e2a189e4e52eaa38e9a8e31dad35a (patch)
tree6962129f10968bd308c9f1009cdd56a6c5d3a676 /libavutil/timer.h
parent6a18c0bc87e38557fa9dd9fcf974f310cfff112e (diff)
downloadffmpeg-33e4cc963d5e2a189e4e52eaa38e9a8e31dad35a.tar.gz
avutil/timer: Add clock_gettime as a fallback of AV_READ_TIME
Reviewed-by: Rémi Denis-Courmont <remi@remlab.net> Reviewed-by: Martin Storsjö <martin@martin.st> Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
Diffstat (limited to 'libavutil/timer.h')
-rw-r--r--libavutil/timer.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/libavutil/timer.h b/libavutil/timer.h
index 2cd299eca3..6bd6a0c645 100644
--- a/libavutil/timer.h
+++ b/libavutil/timer.h
@@ -46,6 +46,8 @@
#include "macos_kperf.h"
#elif HAVE_MACH_ABSOLUTE_TIME
#include <mach/mach_time.h>
+#elif HAVE_CLOCK_GETTIME
+#include <time.h>
#endif
#include "common.h"
@@ -70,6 +72,14 @@
# define AV_READ_TIME gethrtime
# elif HAVE_MACH_ABSOLUTE_TIME
# define AV_READ_TIME mach_absolute_time
+# elif HAVE_CLOCK_GETTIME && defined(CLOCK_MONOTONIC)
+ static inline int64_t ff_read_time(void)
+ {
+ struct timespec ts;
+ clock_gettime(CLOCK_MONOTONIC, &ts);
+ return ts.tv_sec * INT64_C(1000000000) + ts.tv_nsec;
+ }
+# define AV_READ_TIME ff_read_time
# endif
#endif