diff options
author | Dudemanguy <random342@airmail.cc> | 2023-01-01 11:16:31 -0600 |
---|---|---|
committer | Dudemanguy <random342@airmail.cc> | 2023-01-03 20:45:39 +0000 |
commit | 4bbb1ccfd75aa5f2a5d4674d86433d334b9f22c8 (patch) | |
tree | a2c4ae63f483c86b175081dfafdca8a85ea9eaf9 /video | |
parent | 24e2251b734da0e50ecc4bba773b6d812103b31d (diff) | |
download | mpv-4bbb1ccfd75aa5f2a5d4674d86433d334b9f22c8.tar.bz2 mpv-4bbb1ccfd75aa5f2a5d4674d86433d334b9f22c8.tar.xz |
wayland: initalize display_fd as -1
In the event of a failed wayland initalization, the display_fd is
actually 0 instead of -1 which would correctly indicate it doesn't
exist. Also move the fd check inside vo_wayland_dispatch_events since
that function shouldn't ever do anything if we don't actually have a
display fd.
Diffstat (limited to 'video')
-rw-r--r-- | video/out/wayland_common.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/video/out/wayland_common.c b/video/out/wayland_common.c index 43e8967003..09a6bdde6e 100644 --- a/video/out/wayland_common.c +++ b/video/out/wayland_common.c @@ -1724,6 +1724,9 @@ static void window_move(struct vo_wayland_state *wl, uint32_t serial) static void vo_wayland_dispatch_events(struct vo_wayland_state *wl, int nfds, int timeout) { + if (wl->display_fd == -1) + return; + struct pollfd fds[2] = { {.fd = wl->display_fd, .events = POLLIN }, {.fd = wl->wakeup_pipe[0], .events = POLLIN }, @@ -1947,6 +1950,7 @@ int vo_wayland_init(struct vo *vo) .refresh_interval = 0, .scaling = 1, .wakeup_pipe = {-1, -1}, + .display_fd = -1, .dnd_fd = -1, .cursor_visible = true, .vo_opts_cache = m_config_cache_alloc(wl, vo->global, &vo_sub_opts), @@ -2346,9 +2350,6 @@ void vo_wayland_wait_events(struct vo *vo, int64_t until_time_us) { struct vo_wayland_state *wl = vo->wl; - if (wl->display_fd == -1) - return; - int64_t wait_us = until_time_us - mp_time_us(); int timeout_ms = MPCLAMP((wait_us + 999) / 1000, 0, 10000); |