summaryrefslogtreecommitdiffstats
path: root/video
diff options
context:
space:
mode:
authorRostislav Pehlivanov <atomnuker@gmail.com>2016-07-29 02:30:07 +0100
committerwm4 <wm4@nowhere>2016-07-30 00:02:39 +0200
commitf918ec4b2b403f60cd534bb52df716af0686b84d (patch)
treef43dc9fcb1d4aba1f533085fb2c3a63d628482b3 /video
parentc3e11f7b7c9aec22f7ecc56feacf42194e7ea727 (diff)
downloadmpv-f918ec4b2b403f60cd534bb52df716af0686b84d.tar.bz2
mpv-f918ec4b2b403f60cd534bb52df716af0686b84d.tar.xz
wayland_common: flush wakeup_pipe on a wakeup
Missed during the recent changes. Also simplify error checking code and check for POLLNVAL as well (the display fd was never actually checked to be valid).
Diffstat (limited to 'video')
-rw-r--r--video/out/wayland_common.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/video/out/wayland_common.c b/video/out/wayland_common.c
index 84bef55b9c..3774e5f8b2 100644
--- a/video/out/wayland_common.c
+++ b/video/out/wayland_common.c
@@ -1124,9 +1124,6 @@ void vo_wayland_wait_events(struct vo *vo, int64_t until_time_us)
struct vo_wayland_state *wl = vo->wayland;
struct wl_display *dp = wl->display.display;
- wl_display_dispatch_pending(dp);
- wl_display_flush(dp);
-
struct pollfd fds[2] = {
{.fd = wl->display.display_fd, .events = POLLIN },
{.fd = wl->wakeup_pipe[0], .events = POLLIN },
@@ -1135,16 +1132,21 @@ void vo_wayland_wait_events(struct vo *vo, int64_t until_time_us)
int64_t wait_us = until_time_us - mp_time_us();
int timeout_ms = MPCLAMP((wait_us + 500) / 1000, 0, 10000);
+ wl_display_dispatch_pending(dp);
+ wl_display_flush(dp);
+
poll(fds, 2, timeout_ms);
- if (fds[0].revents & POLLERR || fds[0].revents & POLLHUP) {
+ if (fds[0].revents & (POLLERR | POLLHUP | POLLNVAL)) {
MP_FATAL(wl, "error occurred on the display fd: "
"closing file descriptor\n");
close(wl->display.display_fd);
mp_input_put_key(vo->input_ctx, MP_KEY_CLOSE_WIN);
- } else if (fds[0].revents & POLLIN) {
- wl_display_dispatch(dp);
- } else if (fds[1].revents & POLLIN) {
- wl_display_dispatch_pending(dp);
}
+
+ if (fds[0].revents & POLLIN)
+ wl_display_dispatch(dp);
+
+ if (fds[1].revents & POLLIN)
+ mp_flush_wakeup_pipe(wl->wakeup_pipe[0]);
}