summaryrefslogtreecommitdiffstats
path: root/video/out/drm_common.c
diff options
context:
space:
mode:
authorKacper Michajłow <kasper93@gmail.com>2023-09-16 04:45:24 +0200
committerDudemanguy <random342@airmail.cc>2023-09-29 20:48:58 +0000
commitdf764bc0c3926ff06902c2ed8609ed7633408550 (patch)
tree9b0332fc95ca0cbbbdc3653fbc06104b62fc4e28 /video/out/drm_common.c
parentcdfd5c280a174b9e126908305c250bedbec0be61 (diff)
downloadmpv-df764bc0c3926ff06902c2ed8609ed7633408550.tar.bz2
mpv-df764bc0c3926ff06902c2ed8609ed7633408550.tar.xz
vo: change vsync base to nanoseconds
There is no reason to use microseconds precision. We have precise timers all all relevant platforms.
Diffstat (limited to 'video/out/drm_common.c')
-rw-r--r--video/out/drm_common.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/video/out/drm_common.c b/video/out/drm_common.c
index 5faf305a6b..4f235956ad 100644
--- a/video/out/drm_common.c
+++ b/video/out/drm_common.c
@@ -943,14 +943,14 @@ static void drm_pflip_cb(int fd, unsigned int msc, unsigned int sec,
struct timespec ts;
if (clock_gettime(CLOCK_MONOTONIC, &ts))
goto fail;
- const uint64_t now_monotonic = ts.tv_sec * 1000000LL + ts.tv_nsec / 1000;
- const uint64_t ust_mp_time = mp_time_us() - (now_monotonic - vsync->ust);
+ int64_t now_monotonic = ts.tv_sec * UINT64_C(1000000000) + 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;
const unsigned int msc_since_enqueue = vsync->msc - frame_vsync->msc;
const unsigned int sbc_since_enqueue = vsync->sbc - frame_vsync->sbc;
- vsync_info->vsync_duration = ust_since_enqueue / msc_since_enqueue;
+ vsync_info->vsync_duration = ust_since_enqueue * 1000 / msc_since_enqueue;
vsync_info->skipped_vsyncs = msc_since_last_flip - 1; // Valid iff swap_buffers is called every vsync
vsync_info->last_queue_display_time = ust_mp_time + (sbc_since_enqueue * vsync_info->vsync_duration);
}