diff options
author | Dudemanguy <random342@airmail.cc> | 2023-01-01 11:16:31 -0600 |
---|---|---|
committer | sfan5 <sfan5@live.de> | 2023-01-24 15:56:57 +0100 |
commit | 5436852bf574b18f940d5ab2c7102be426cddba2 (patch) | |
tree | a55b9d16eb90f120a3a30ca256ea1d67998f02a7 /video | |
parent | 6076691b94bcedab65a70d5ddafd5856137a88ed (diff) | |
download | mpv-5436852bf574b18f940d5ab2c7102be426cddba2.tar.bz2 mpv-5436852bf574b18f940d5ab2c7102be426cddba2.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 c4c7582957..87b4a814f5 100644 --- a/video/out/wayland_common.c +++ b/video/out/wayland_common.c @@ -1698,6 +1698,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 }, @@ -1912,6 +1915,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), @@ -2284,9 +2288,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); |