diff options
author | Hiltjo Posthuma <hiltjo@codemadness.org> | 2015-01-19 18:47:59 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2015-01-19 19:01:08 +0100 |
commit | ffaf4af230b92eb94fdf31784ca323cc931822e3 (patch) | |
tree | 8d2c2c5de8833c464dc38684f29f7c28135fa7fc | |
parent | 513344648fa0ad0c102993ce492ddbef87680a64 (diff) | |
download | mpv-ffaf4af230b92eb94fdf31784ca323cc931822e3.tar.bz2 mpv-ffaf4af230b92eb94fdf31784ca323cc931822e3.tar.xz |
win32: use monotonic clock on windows if possible
-rw-r--r-- | osdep/timer-win2.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/osdep/timer-win2.c b/osdep/timer-win2.c index ed09ed18db..fbbdc923f1 100644 --- a/osdep/timer-win2.c +++ b/osdep/timer-win2.c @@ -36,12 +36,22 @@ void mp_sleep_us(int64_t us) 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) { struct timeval tv; gettimeofday(&tv,NULL); return tv.tv_sec * 1000000LL + tv.tv_usec; } +#endif static void restore_timer(void) { |