From bf660b1d8dc1905527bb5919b1034c7b43c55dac Mon Sep 17 00:00:00 2001 From: Kurt Kartaltepe Date: Thu, 31 Mar 2022 21:18:10 -0700 Subject: [PATCH] linux-pipewire: Version check call to pw_deinit Per upstream this function is not supposed to be called by users of PipeWire, and will crash when called twice. Instead only call it on recent versions of PipeWire where it is safe to call. This also removes the nearly empty pipewire-common files. --- plugins/linux-pipewire/CMakeLists.txt | 2 -- plugins/linux-pipewire/linux-pipewire.c | 8 +++--- plugins/linux-pipewire/pipewire-common.c | 33 ------------------------ plugins/linux-pipewire/pipewire-common.h | 24 ----------------- 4 files changed, 5 insertions(+), 62 deletions(-) delete mode 100644 plugins/linux-pipewire/pipewire-common.c delete mode 100644 plugins/linux-pipewire/pipewire-common.h diff --git a/plugins/linux-pipewire/CMakeLists.txt b/plugins/linux-pipewire/CMakeLists.txt index da495b83f..26ec5eb13 100644 --- a/plugins/linux-pipewire/CMakeLists.txt +++ b/plugins/linux-pipewire/CMakeLists.txt @@ -33,8 +33,6 @@ add_library(OBS::pipewire ALIAS linux-pipewire) target_sources( linux-pipewire PRIVATE linux-pipewire.c - pipewire-common.c - pipewire-common.h pipewire.c pipewire.h pipewire-capture.c diff --git a/plugins/linux-pipewire/linux-pipewire.c b/plugins/linux-pipewire/linux-pipewire.c index edbb0c636..98c21642e 100644 --- a/plugins/linux-pipewire/linux-pipewire.c +++ b/plugins/linux-pipewire/linux-pipewire.c @@ -22,7 +22,7 @@ #include #include -#include "pipewire-common.h" +#include #include "pipewire-capture.h" OBS_DECLARE_MODULE() @@ -34,7 +34,7 @@ MODULE_EXPORT const char *obs_module_description(void) bool obs_module_load(void) { - obs_pipewire_load(); + pw_init(NULL, NULL); // OBS PipeWire Screen Capture switch (obs_get_nix_platform()) { @@ -53,5 +53,7 @@ bool obs_module_load(void) void obs_module_unload(void) { - obs_pipewire_unload(); +#if PW_CHECK_VERSION(0, 3, 49) + pw_deinit(); +#endif } diff --git a/plugins/linux-pipewire/pipewire-common.c b/plugins/linux-pipewire/pipewire-common.c deleted file mode 100644 index 9dae00210..000000000 --- a/plugins/linux-pipewire/pipewire-common.c +++ /dev/null @@ -1,33 +0,0 @@ -/* pipewire-common.c - * - * Copyright 2021 columbarius - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - * SPDX-License-Identifier: GPL-2.0-or-later - */ - -#include - -#include "pipewire-common.h" - -void obs_pipewire_load(void) -{ - pw_init(NULL, NULL); -} - -void obs_pipewire_unload(void) -{ - pw_deinit(); -} diff --git a/plugins/linux-pipewire/pipewire-common.h b/plugins/linux-pipewire/pipewire-common.h deleted file mode 100644 index 44ffc42a8..000000000 --- a/plugins/linux-pipewire/pipewire-common.h +++ /dev/null @@ -1,24 +0,0 @@ -/* pipewire-common.h - * - * Copyright 2021 columbarius - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - * SPDX-License-Identifier: GPL-2.0-or-later - */ - -#pragma once - -void obs_pipewire_load(void); -void obs_pipewire_unload(void);