summaryrefslogtreecommitdiffstats
path: root/video/out/wayland_common.c
diff options
context:
space:
mode:
authorDudemanguy <random342@airmail.cc>2020-08-15 16:07:53 -0500
committerDudemanguy <random342@airmail.cc>2020-08-16 18:34:09 +0000
commite9cde72536b60fc1bad304aa02a4638f63de258b (patch)
treea9d0e23d788a83c77b0bd9c263fb95c3d5b01e6f /video/out/wayland_common.c
parent8ec61c366a0e0fad0732102782ba182a75e7508c (diff)
downloadmpv-e9cde72536b60fc1bad304aa02a4638f63de258b.tar.bz2
mpv-e9cde72536b60fc1bad304aa02a4638f63de258b.tar.xz
wayland: refactor presentation time
The motivation for this change was a segfault caused by e107342 which has complicated reasons for occuring (i.e. I'm not 100% sure but I think it is a really weird race). The major part of this commit is moving the initialization of presentation listener to the frame_callback function. Calling it in swap_buffers worked fine but in practice it meant a lot of meaningless function calls if a window was hidden (the presentation would just be immediately discarded). By calling it in frame_callback, we ensure the listener is only created when it is possible to receive a presentation event. Of course calling the presentation listener in feedback_presented or feedback_discarded was considered, but ultimately these events are too slow. Receiving the ust/msc/sbc triplet here and then passing it to mpv results in higher vsync judder since there is (likely) not enough time before the next pageflip. By design, the frame callback is meant to give us as much time as possible before the next repaint so calling it here is probably optimal. Additionally, we can make better use of the feedback_discarded event. The wp_presentation_feedback should not be destroyed here. It will be taken care of either when we get feedback again or when the player quits. Instead what we can do is set a bool that tells wayland_sync_swap to update itself based on mp_time delta. In practice, the result is not any different than before, but it should be more understandable what is going on now. Of course, the segfault mentioned at the beginning is fixed with this as well.
Diffstat (limited to 'video/out/wayland_common.c')
-rw-r--r--video/out/wayland_common.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/video/out/wayland_common.c b/video/out/wayland_common.c
index 99aa8ee018..993c7b0e54 100644
--- a/video/out/wayland_common.c
+++ b/video/out/wayland_common.c
@@ -1607,10 +1607,9 @@ void wayland_sync_swap(struct vo_wayland_state *wl)
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) {
+ // If the presentation event was discarded, update the values based on
+ // the difference in mp_time.
+ if (wl->presentation_discarded) {
wl->sync[index].ust += mp_time - wl->sync[index].last_mp_time;
wl->sync[index].msc += 1;
wl->sync[index].sbc += 1;