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>
Signed-off-by: Paul B Mahol <onemda@gmail.com>
This commit is contained in:
Zhao Zhili 2024-06-07 21:44:50 +08:00 committed by Paul B Mahol
parent 2c0562679e
commit 00c8f6ae03

View File

@ -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