mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-01-24 13:56:33 +02:00
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>
This commit is contained in:
parent
6a18c0bc87
commit
33e4cc963d
@ -46,6 +46,8 @@
|
|||||||
#include "macos_kperf.h"
|
#include "macos_kperf.h"
|
||||||
#elif HAVE_MACH_ABSOLUTE_TIME
|
#elif HAVE_MACH_ABSOLUTE_TIME
|
||||||
#include <mach/mach_time.h>
|
#include <mach/mach_time.h>
|
||||||
|
#elif HAVE_CLOCK_GETTIME
|
||||||
|
#include <time.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
@ -70,6 +72,14 @@
|
|||||||
# define AV_READ_TIME gethrtime
|
# define AV_READ_TIME gethrtime
|
||||||
# elif HAVE_MACH_ABSOLUTE_TIME
|
# elif HAVE_MACH_ABSOLUTE_TIME
|
||||||
# define AV_READ_TIME 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
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user