summaryrefslogtreecommitdiffstats
path: root/video/out/wayland_common.h
diff options
context:
space:
mode:
authordudemanguy <random342@airmail.cc>2019-10-07 15:58:36 -0500
committerDudemanguy911 <random342@airmail.cc>2019-10-10 17:41:19 +0000
commitea4685b233090bb155cfa4ec6bf87f421a553168 (patch)
tree35e1f69c4fa348401a6bbab877a2fb096910ba6b /video/out/wayland_common.h
parente0895e097bcf15cdabc93f340dae24a88b0dc89c (diff)
downloadmpv-ea4685b233090bb155cfa4ec6bf87f421a553168.tar.bz2
mpv-ea4685b233090bb155cfa4ec6bf87f421a553168.tar.xz
wayland: use callback flag + poll for buffer swap
The old way of using wayland in mpv relied on an external renderloop for semi-accurate timings. This had multiple issues though. Display sync would break whenever the window was hidden (since the frame callback stopped being executed) which was really annoying. Also the entire external renderloop logic was kind of fragile and didn't play well with mpv's internal structure (i.e. using presentation time in that old paradigm breaks stats.lua). Basically the problem is that swap buffers blocks on wayland which is crap whenever you hide the mpv window since it looks up the entire player. So you have to make swap buffers not block, but this has a different problem. Timings will be terrible if you use the unblocked swap buffers call. Based on some discussion in #wayland, the trick here is relatively simple and works well enough for our purposes. Instead we basically build a way to block with a timeout in the wayland buffer swap functions. A bool is set in the frame callback function that indicates whether or not mpv is waiting for a frame to be displayed. In the actual buffer swap function, we enter into a while loop waiting for this flag to be set. At the same time, the wl_display is polled to block the thread and wakeup if it receives any events from the compositor. This loop only breaks if enough time has passed or if the frame callback bool is received. In the near future, it is better to set whether or not frame a frame has been displayed in the presentation feedback. However as a first pass, doing it in the frame callback is more than good enough. The "downside" is that we render frames that aren't actually shown on screen when the player is hidden (it seems like wayland people don't like that). But who cares. Accurate timings are way more important. It's probably not too hard to add that behavior back in the player though.
Diffstat (limited to 'video/out/wayland_common.h')
-rw-r--r--video/out/wayland_common.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/video/out/wayland_common.h b/video/out/wayland_common.h
index b9ce1c53ce..1415c6935d 100644
--- a/video/out/wayland_common.h
+++ b/video/out/wayland_common.h
@@ -56,6 +56,7 @@ struct vo_wayland_state {
bool fullscreen;
bool maximized;
bool configured;
+ bool callback_wait;
int wakeup_pipe[2];
int pending_vo_events;
int mouse_x;
@@ -112,5 +113,6 @@ void vo_wayland_check_events(struct vo *vo);
void vo_wayland_uninit(struct vo *vo);
void vo_wayland_wakeup(struct vo *vo);
void vo_wayland_wait_events(struct vo *vo, int64_t until_time_us);
+void vo_wayland_wait_frame(struct vo_wayland_state *wl);
#endif /* MPLAYER_WAYLAND_COMMON_H */