From d558e87b5138739db02bd501f8ab02ca2503c6dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A1s=20P=C5=91cze?= Date: Thu, 17 Feb 2022 02:38:06 +0100 Subject: [PATCH] pipewire: module-x11-bell: remove a function `x11_close()` is no longer needed since X11 errors are now considered fatal, so `module_destroy()` will be called if `x11_connect()` fails, which means that the code from `x11_close()` can be moved there. --- src/modules/module-x11-bell.c | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/src/modules/module-x11-bell.c b/src/modules/module-x11-bell.c index 22b53e4bb..b19b91953 100644 --- a/src/modules/module-x11-bell.c +++ b/src/modules/module-x11-bell.c @@ -154,18 +154,6 @@ static void display_io(void *data, int fd, uint32_t mask) } } -static void x11_close(struct impl *impl) -{ - if (impl->source) { - pw_loop_destroy_source(impl->loop, impl->source); - impl->source = NULL; - } - if (impl->display) { - XCloseDisplay(impl->display); - impl->display = NULL; - } -} - static int x11_connect(struct impl *impl, const char *name) { int res, major, minor; @@ -209,8 +197,6 @@ static int x11_connect(struct impl *impl, const char *name) res = 0; error: - if (res < 0) - x11_close(impl); return res; } @@ -221,7 +207,11 @@ static void module_destroy(void *data) if (impl->module) spa_hook_remove(&impl->module_listener); - x11_close(impl); + if (impl->source) + pw_loop_destroy_source(impl->loop, impl->source); + + if (impl->display) + XCloseDisplay(impl->display); if (impl->thread_loop) pw_thread_loop_destroy(impl->thread_loop);