From 33e4cc963d5e2a189e4e52eaa38e9a8e31dad35a Mon Sep 17 00:00:00 2001 From: Zhao Zhili Date: Fri, 7 Jun 2024 21:44:50 +0800 Subject: [PATCH] avutil/timer: Add clock_gettime as a fallback of AV_READ_TIME MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Rémi Denis-Courmont Reviewed-by: Martin Storsjö Signed-off-by: Zhao Zhili --- libavutil/timer.h | 10 ++++++++++ 1 file changed, 10 insertions(+) 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 +#elif HAVE_CLOCK_GETTIME +#include #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