summaryrefslogtreecommitdiffstats
path: root/osdep/timer.c
diff options
context:
space:
mode:
authorKacper Michajłow <kasper93@gmail.com>2023-09-15 16:52:27 +0200
committerDudemanguy <random342@airmail.cc>2023-09-29 20:48:58 +0000
commit318b5471a18e464cfcd1f7222da7853b7056f9fc (patch)
tree83eee44726747e83fa626289d4febc25d377ce48 /osdep/timer.c
parentd2630877132edac876779ff31ae61685f09199c4 (diff)
downloadmpv-318b5471a18e464cfcd1f7222da7853b7056f9fc.tar.bz2
mpv-318b5471a18e464cfcd1f7222da7853b7056f9fc.tar.xz
win32/pthread: don't convert time through unrelated timer
Just keep it directly as mp_time for internal implementation.
Diffstat (limited to 'osdep/timer.c')
-rw-r--r--osdep/timer.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/osdep/timer.c b/osdep/timer.c
index 58a44043ca..3e48329ba2 100644
--- a/osdep/timer.c
+++ b/osdep/timer.c
@@ -27,6 +27,7 @@
#include "common/msg.h"
#include "misc/random.h"
#include "timer.h"
+#include "config.h"
static uint64_t raw_time_offset;
static pthread_once_t timer_init_once = PTHREAD_ONCE_INIT;
@@ -89,6 +90,7 @@ int64_t mp_time_ns_add(int64_t time_ns, double timeout_sec)
return time_ns + ti;
}
+#if !HAVE_WIN32_INTERNAL_PTHREADS
static int get_realtime(struct timespec *out_ts)
{
#if defined(_POSIX_TIMERS) && _POSIX_TIMERS > 0
@@ -102,6 +104,7 @@ static int get_realtime(struct timespec *out_ts)
return 0;
#endif
}
+#endif
struct timespec mp_time_us_to_realtime(int64_t time_us)
{
@@ -111,12 +114,17 @@ struct timespec mp_time_us_to_realtime(int64_t time_us)
struct timespec mp_time_ns_to_realtime(int64_t time_ns)
{
struct timespec ts = {0};
+
+#if !HAVE_WIN32_INTERNAL_PTHREADS
if (get_realtime(&ts) != 0)
return ts;
+ int64_t time_rel = time_ns - mp_time_ns();
+#else
+ int64_t time_rel = time_ns;
+#endif
// clamp to 1000 days in the future
- int64_t time_rel = MPMIN(mp_time_ns() - time_ns,
- 1000 * 24 * 60 * 60 * INT64_C(1000000000));
+ time_rel = MPMIN(time_rel, 1000 * 24 * 60 * 60 * INT64_C(1000000000));
ts.tv_sec += time_rel / INT64_C(1000000000);
ts.tv_nsec += time_rel % INT64_C(1000000000);