summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKacper Michajłow <kasper93@gmail.com>2023-10-22 04:31:36 +0200
committerDudemanguy <random342@airmail.cc>2023-10-26 16:49:38 +0000
commit34d99840a5cee8907cf4b2528efb1670a8f51744 (patch)
tree4b1f1847c9f81eb650d29cb519a44ed5d3d9e404
parent032b7de97f1c8c28358a96e9ecfac87d6621a4fb (diff)
downloadmpv-34d99840a5cee8907cf4b2528efb1670a8f51744.tar.bz2
mpv-34d99840a5cee8907cf4b2528efb1670a8f51744.tar.xz
timer: use MP_TIME macros
-rw-r--r--osdep/poll_wrapper.c4
-rw-r--r--osdep/timer-linux.c6
-rw-r--r--video/out/drm_common.c2
-rw-r--r--video/out/present_sync.c2
-rw-r--r--video/out/wayland_common.c2
5 files changed, 8 insertions, 8 deletions
diff --git a/osdep/poll_wrapper.c b/osdep/poll_wrapper.c
index 4494392912..9f8885fd1c 100644
--- a/osdep/poll_wrapper.c
+++ b/osdep/poll_wrapper.c
@@ -29,8 +29,8 @@ int mp_poll(struct pollfd *fds, int nfds, int64_t timeout_ns)
{
#if HAVE_PPOLL
struct timespec ts;
- ts.tv_sec = timeout_ns / UINT64_C(1000000000);
- ts.tv_nsec = timeout_ns % UINT64_C(1000000000);
+ ts.tv_sec = timeout_ns / MP_TIME_S_TO_NS(1);
+ ts.tv_nsec = timeout_ns % MP_TIME_S_TO_NS(1);
return ppoll(fds, nfds, &ts, NULL);
#endif
return poll(fds, nfds, timeout_ns / 1e6);
diff --git a/osdep/timer-linux.c b/osdep/timer-linux.c
index ff4b137cb2..25bb70bcca 100644
--- a/osdep/timer-linux.c
+++ b/osdep/timer-linux.c
@@ -27,8 +27,8 @@ void mp_sleep_ns(int64_t ns)
if (ns < 0)
return;
struct timespec ts;
- ts.tv_sec = ns / UINT64_C(1000000000);
- ts.tv_nsec = ns % UINT64_C(1000000000);
+ ts.tv_sec = ns / MP_TIME_S_TO_NS(1);
+ ts.tv_nsec = ns % MP_TIME_S_TO_NS(1);
nanosleep(&ts, NULL);
}
@@ -40,7 +40,7 @@ uint64_t mp_raw_time_ns(void)
#else
timespec_get(&tp, TIME_UTC);
#endif
- return tp.tv_sec * UINT64_C(1000000000) + tp.tv_nsec;
+ return MP_TIME_S_TO_NS(tp.tv_sec) + tp.tv_nsec;
}
void mp_raw_time_init(void)
diff --git a/video/out/drm_common.c b/video/out/drm_common.c
index d3cb58e8a6..67cac7a908 100644
--- a/video/out/drm_common.c
+++ b/video/out/drm_common.c
@@ -946,7 +946,7 @@ static void drm_pflip_cb(int fd, unsigned int msc, unsigned int sec,
struct timespec ts;
if (clock_gettime(CLOCK_MONOTONIC, &ts))
goto fail;
- int64_t now_monotonic = ts.tv_sec * UINT64_C(1000000000) + ts.tv_nsec;
+ int64_t now_monotonic = MP_TIME_S_TO_NS(ts.tv_sec) + ts.tv_nsec;
int64_t ust_mp_time = mp_time_ns() - (now_monotonic - vsync->ust * 1000);
const uint64_t ust_since_enqueue = vsync->ust - frame_vsync->ust;
diff --git a/video/out/present_sync.c b/video/out/present_sync.c
index e7112ccc39..618c53e6a2 100644
--- a/video/out/present_sync.c
+++ b/video/out/present_sync.c
@@ -70,7 +70,7 @@ void present_sync_swap(struct mp_present *present)
if (clock_gettime(CLOCK_MONOTONIC, &ts))
return;
- int64_t now_monotonic = ts.tv_sec * UINT64_C(1000000000) + ts.tv_nsec;
+ int64_t now_monotonic = MP_TIME_S_TO_NS(ts.tv_sec) + ts.tv_nsec;
int64_t ust_mp_time = mp_time_ns() - (now_monotonic - ust);
present->last_queue_display_time = ust_mp_time;
diff --git a/video/out/wayland_common.c b/video/out/wayland_common.c
index d5ab2fe1c9..144ff78284 100644
--- a/video/out/wayland_common.c
+++ b/video/out/wayland_common.c
@@ -1157,7 +1157,7 @@ static void feedback_presented(void *data, struct wp_presentation_feedback *fbac
// - these values are updated every time the compositor receives feedback.
int64_t sec = (uint64_t) tv_sec_lo + ((uint64_t) tv_sec_hi << 32);
- int64_t ust = sec * UINT64_C(1000000000) + (uint64_t) tv_nsec;
+ int64_t ust = MP_TIME_S_TO_NS(sec) + (uint64_t) tv_nsec;
int64_t msc = (uint64_t) seq_lo + ((uint64_t) seq_hi << 32);
present_update_sync_values(wl->present, ust, msc);
}