diff options
author | wm4 <wm4@nowhere> | 2014-05-18 16:36:08 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2014-05-18 19:20:32 +0200 |
commit | f47a4fc3d900e14653bc059717e2805ad4964a67 (patch) | |
tree | a8ca8944a10c15bbb46239db62a56940a0d3f7b1 /osdep/timer.h | |
parent | e209e44ca2fef86ec2ec5513bbb63d4d68ff97b5 (diff) | |
download | mpv-f47a4fc3d900e14653bc059717e2805ad4964a67.tar.bz2 mpv-f47a4fc3d900e14653bc059717e2805ad4964a67.tar.xz |
threads: use mpv time for mpthread_cond_timedwait wrapper
Use the time as returned by mp_time_us() for mpthread_cond_timedwait(),
instead of calculating the struct timespec value based on a timeout.
This (probably) makes it easier to wait for a specific deadline.
Diffstat (limited to 'osdep/timer.h')
-rw-r--r-- | osdep/timer.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/osdep/timer.h b/osdep/timer.h index efb596765a..bc0e5252c9 100644 --- a/osdep/timer.h +++ b/osdep/timer.h @@ -44,4 +44,11 @@ void mp_sleep_us(int64_t us); // first call will return 0, instead of the absolute current time.) int64_t mp_time_relative_us(int64_t *t); +// Add a time in seconds to the given time in microseconds, and return it. +// Takes care of possible overflows. Never returns a negative or 0 time. +int64_t mp_add_timeout(int64_t time_us, double timeout_sec); + +// Convert the mp time in microseconds to a timespec using CLOCK_REALTIME. +struct timespec mp_time_us_to_timespec(int64_t time_us); + #endif /* MPLAYER_TIMER_H */ |