summaryrefslogtreecommitdiffstats
path: root/video/out/wayland_common.c
diff options
context:
space:
mode:
authorDudemanguy <random342@airmail.cc>2023-01-08 13:31:03 -0600
committerDudemanguy <random342@airmail.cc>2023-01-08 20:42:42 +0000
commitd73fc7912a46d4cb9c3e07f01f5ae2d64e7d9ff5 (patch)
treed6e6ee882cb403d90e220f2ab16d0d732d506fb5 /video/out/wayland_common.c
parente4e0e7dfcf3a79f7bb510e11d059bcf8d1e93bd6 (diff)
downloadmpv-d73fc7912a46d4cb9c3e07f01f5ae2d64e7d9ff5.tar.bz2
mpv-d73fc7912a46d4cb9c3e07f01f5ae2d64e7d9ff5.tar.xz
wayland: cleanup on vo_wayland_init error
Instead of just returning true/false, it's better to have this function cleanup itself. We can eliminate some redundant uninit calls elsewhere in the code as well.
Diffstat (limited to 'video/out/wayland_common.c')
-rw-r--r--video/out/wayland_common.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/video/out/wayland_common.c b/video/out/wayland_common.c
index ed7e68c9ad..dadc93a5ef 100644
--- a/video/out/wayland_common.c
+++ b/video/out/wayland_common.c
@@ -1953,10 +1953,10 @@ bool vo_wayland_init(struct vo *vo)
wl_list_init(&wl->output_list);
if (!wl->display)
- return false;
+ goto err;
if (create_input(wl))
- return false;
+ goto err;
wl->registry = wl_display_get_registry(wl->display);
wl_registry_add_listener(wl->registry, &registry_listener, wl);
@@ -1967,24 +1967,24 @@ bool vo_wayland_init(struct vo *vo)
if (!wl->surface) {
MP_FATAL(wl, "Compositor doesn't support %s (ver. 4)\n",
wl_compositor_interface.name);
- return false;
+ goto err;
}
if (!wl->wm_base) {
MP_FATAL(wl, "Compositor doesn't support the required %s protocol!\n",
xdg_wm_base_interface.name);
- return false;
+ goto err;
}
if (!wl_list_length(&wl->output_list)) {
MP_FATAL(wl, "No outputs found or compositor doesn't support %s (ver. 2)\n",
wl_output_interface.name);
- return false;
+ goto err;
}
/* Can't be initialized during registry due to multi-protocol dependence */
if (create_xdg_surface(wl))
- return false;
+ goto err;
if (wl->subcompositor) {
wl->video_subsurface = wl_subcompositor_get_subsurface(wl->subcompositor, wl->video_surface, wl->surface);
@@ -2063,6 +2063,10 @@ bool vo_wayland_init(struct vo *vo)
wl_display_roundtrip(wl->display);
return true;
+
+err:
+ vo_wayland_uninit(vo);
+ return false;
}
int vo_wayland_reconfig(struct vo *vo)