1
0
mirror of https://github.com/mpv-player/mpv synced 2025-05-04 17:19:29 +00:00

win32: use monotonic clock on windows if possible

This commit is contained in:
Hiltjo Posthuma 2015-01-19 18:47:59 +01:00 committed by wm4
parent 513344648f
commit ffaf4af230

View File

@ -36,12 +36,22 @@ void mp_sleep_us(int64_t us)
Sleep(us / 1000); Sleep(us / 1000);
} }
#if defined(_POSIX_TIMERS) && _POSIX_TIMERS > 0 && defined(CLOCK_MONOTONIC)
uint64_t mp_raw_time_us(void)
{
struct timespec ts;
if (clock_gettime(CLOCK_MONOTONIC, &ts))
abort();
return ts.tv_sec * 1000000LL + ts.tv_nsec / 1000;
}
#else
uint64_t mp_raw_time_us(void) uint64_t mp_raw_time_us(void)
{ {
struct timeval tv; struct timeval tv;
gettimeofday(&tv,NULL); gettimeofday(&tv,NULL);
return tv.tv_sec * 1000000LL + tv.tv_usec; return tv.tv_sec * 1000000LL + tv.tv_usec;
} }
#endif
static void restore_timer(void) static void restore_timer(void)
{ {