summaryrefslogtreecommitdiffstats
path: root/osdep/timer.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-05-11 23:44:36 +0200
committerDiogo Franco (Kovensky) <diogomfranco@gmail.com>2015-05-15 10:30:15 +0900
commit37ad3e79dd03cecc4be3a7341fdf69f96873d2eb (patch)
treeae9e6ec463c69918c334c637901427a94013c017 /osdep/timer.c
parent328d0c7fc326abce5fc1783e74cdd082c87d4986 (diff)
downloadmpv-37ad3e79dd03cecc4be3a7341fdf69f96873d2eb.tar.bz2
mpv-37ad3e79dd03cecc4be3a7341fdf69f96873d2eb.tar.xz
threads: use utility+POSIX functions instead of weird wrappers
There is not much of a reason to have these wrappers around. Use POSIX standard functions directly, and use a separate utility function to take care of the timespec calculations. (Course POSIX for using this weird format for time values.) (cherry picked from commit 92b9d75d7256be71d8c8b18438af9494b78f0e96)
Diffstat (limited to 'osdep/timer.c')
-rw-r--r--osdep/timer.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/osdep/timer.c b/osdep/timer.c
index 643d7cbb9b..053d12dd7c 100644
--- a/osdep/timer.c
+++ b/osdep/timer.c
@@ -116,6 +116,11 @@ struct timespec mp_time_us_to_timespec(int64_t time_us)
return ts;
}
+struct timespec mp_rel_time_to_timespec(double timeout_sec)
+{
+ return mp_time_us_to_timespec(mp_add_timeout(mp_time_us(), timeout_sec));
+}
+
#if 0
#include <stdio.h>
#include "threads.h"
@@ -138,7 +143,8 @@ int main(void) {
#if TEST_SLEEP
mp_sleep_us(delay);
#else
- mpthread_cond_timedwait(&cnd, &mtx, r + delay);
+ struct timespec ts = mp_time_us_to_timespec(r + delay);
+ pthread_cond_timedwait(&cnd, &mtx, &ts);
#endif
j = (mp_time_us() - r) - delay;
printf("sleep time: t=%"PRId64" sleep=%8i err=%5i\n", r, delay, (int)j);