From f918ec4b2b403f60cd534bb52df716af0686b84d Mon Sep 17 00:00:00 2001 From: Rostislav Pehlivanov Date: Fri, 29 Jul 2016 02:30:07 +0100 Subject: 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). --- video/out/wayland_common.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'video') 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]); } -- cgit v1.2.3