diff options
author | wm4 <wm4@nowhere> | 2014-02-28 23:18:52 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2014-02-28 23:18:52 +0100 |
commit | 1f8a400ad746eb3b03b243c53104f39f18488a94 (patch) | |
tree | e62c95d37579f5d2a99c8056dc78408d65926ad8 /osdep/timer.c | |
parent | 97409ec4e652a2d56c3d77764cf9858b19b5cea9 (diff) | |
download | mpv-1f8a400ad746eb3b03b243c53104f39f18488a94.tar.bz2 mpv-1f8a400ad746eb3b03b243c53104f39f18488a94.tar.xz |
timer: add utility function to get relative time
Diffstat (limited to 'osdep/timer.c')
-rw-r--r-- | osdep/timer.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/osdep/timer.c b/osdep/timer.c index f2c64959ab..4f506b3d46 100644 --- a/osdep/timer.c +++ b/osdep/timer.c @@ -19,6 +19,7 @@ #include <pthread.h> #include "timer.h" +#include "common/msg.h" static uint64_t raw_time_offset; pthread_once_t timer_init_once = PTHREAD_ONCE_INIT; @@ -49,6 +50,16 @@ double mp_time_sec(void) return mp_time_us() / (double)(1000 * 1000); } +int64_t mp_time_relative_us(int64_t *t) +{ + int64_t r = 0; + int64_t now = mp_time_us(); + if (*t) + r = now - *t; + *t = now; + return r; +} + #if 0 #include <stdio.h> |