diff options
author | Dudemanguy <random342@airmail.cc> | 2020-08-21 22:22:10 -0500 |
---|---|---|
committer | Dudemanguy <random342@airmail.cc> | 2020-08-22 20:43:49 +0000 |
commit | b0f0be76783c443413115fe33cc7137ef21e98a8 (patch) | |
tree | 5498fecab0201e7910b08cc8fbef3e885ed3a0be /video/out/wayland_common.c | |
parent | 85f38a9765303a79650013591334e89f9047d4e7 (diff) | |
download | mpv-b0f0be76783c443413115fe33cc7137ef21e98a8.tar.bz2 mpv-b0f0be76783c443413115fe33cc7137ef21e98a8.tar.xz |
wayland: simplify presentation time
Why on earth did I ever bother with this dumb crap? If we do not have
any presentation statistics, just set the relevant vo_sync_info values
to -1 to disable it. It's much simpler than using mp deltas and trying
to keep up with mpv's clock. This also appears to fix audio/video
desynchronization if you start a video with the pause flag, move it out
of view, and then unpause it. Technically harmless since the video
wasn't even in view and putting back in view recovered it, but a quieter
terminal is better.
Diffstat (limited to 'video/out/wayland_common.c')
-rw-r--r-- | video/out/wayland_common.c | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/video/out/wayland_common.c b/video/out/wayland_common.c index ad752218f9..d795f42998 100644 --- a/video/out/wayland_common.c +++ b/video/out/wayland_common.c @@ -1616,19 +1616,18 @@ void queue_new_sync(struct vo_wayland_state *wl) void wayland_sync_swap(struct vo_wayland_state *wl) { int index = wl->sync_size - 1; - int64_t mp_time = mp_time_us(); - - wl->last_skipped_vsyncs = 0; // If these are the same, presentation feedback has not been received. - // This will happen if the window is obscured/hidden in some way. Update - // the values based on the difference in mp_time. - if (wl->sync[index].ust == wl->last_ust && wl->last_ust) { - wl->sync[index].ust += mp_time - wl->sync[index].last_mp_time; - wl->sync[index].msc += 1; - wl->sync[index].sbc += 1; + // This will happen if the window is obscured/hidden in some way. Set + // these values to -1 to disable presentation feedback in mpv's core. + if (wl->sync[index].ust == wl->last_ust) { + wl->last_skipped_vsyncs = -1; + wl->vsync_duration = -1; + wl->last_queue_display_time = -1; + return; } - wl->sync[index].last_mp_time = mp_time; + + wl->last_skipped_vsyncs = 0; int64_t ust_passed = wl->sync[index].ust ? wl->sync[index].ust - wl->last_ust: 0; wl->last_ust = wl->sync[index].ust; @@ -1647,7 +1646,7 @@ void wayland_sync_swap(struct vo_wayland_state *wl) } uint64_t now_monotonic = ts.tv_sec * 1000000LL + ts.tv_nsec / 1000; - uint64_t ust_mp_time = mp_time - (now_monotonic - wl->sync[index].ust); + uint64_t ust_mp_time = mp_time_us() - (now_monotonic - wl->sync[index].ust); wl->last_sbc_mp_time = ust_mp_time; } |