summaryrefslogtreecommitdiffstats
path: root/video/out
diff options
context:
space:
mode:
authorKurt Kartaltepe <kkartaltepe@gmail.com>2021-11-24 16:40:31 -0800
committerDudemanguy <random342@airmail.cc>2021-11-25 04:09:31 +0000
commit79bfcc672343ddbc348e040ad899d61a0bafc050 (patch)
tree114f2d248b4984088585d09697e03be590f59392 /video/out
parenta6e5eba6ab5909bbd43fe11c8cb79d7e926aedb9 (diff)
downloadmpv-79bfcc672343ddbc348e040ad899d61a0bafc050.tar.bz2
mpv-79bfcc672343ddbc348e040ad899d61a0bafc050.tar.xz
wayland: cancel prepared reads when no events
A read can be prepared on the wayland display FD that is never actually read. This occurs when events are triggered on other FDs in the fd set. This change cancels a prepared read if poll reported no events for it. This fixes some hangs due to how nvidia's EGL implementation polls on the wayland fd unlike mesa implementations. It is based on nvidia's proposed fix for qt's similar message pump in https://codereview.qt-project.org/c/qt/qtwayland/+/373473 Signed-off-by: Kurt Kartaltepe <kkartaltepe@gmail.com>
Diffstat (limited to 'video/out')
-rw-r--r--video/out/wayland_common.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/video/out/wayland_common.c b/video/out/wayland_common.c
index 62f471210b..cae0c6a5d3 100644
--- a/video/out/wayland_common.c
+++ b/video/out/wayland_common.c
@@ -1518,21 +1518,23 @@ static void vo_wayland_dispatch_events(struct vo_wayland_state *wl, int nfds, in
poll(fds, nfds, timeout);
+ if (fds[0].revents & POLLIN) {
+ wl_display_read_events(wl->display);
+ } else {
+ wl_display_cancel_read(wl->display);
+ }
+
if (fds[0].revents & (POLLERR | POLLHUP | POLLNVAL)) {
MP_FATAL(wl, "Error occurred on the display fd, closing\n");
- wl_display_cancel_read(wl->display);
close(wl->display_fd);
wl->display_fd = -1;
mp_input_put_key(wl->vo->input_ctx, MP_KEY_CLOSE_WIN);
- } else {
- wl_display_read_events(wl->display);
}
- if (fds[0].revents & POLLIN)
- wl_display_dispatch_pending(wl->display);
-
if (fds[1].revents & POLLIN)
mp_flush_wakeup_pipe(wl->wakeup_pipe[0]);
+
+ wl_display_dispatch_pending(wl->display);
}
/* Non-static */