From db0c224b060598d223e0cd49860a0e87e9f27355 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Danis?= Date: Wed, 22 Jul 2020 14:50:38 +0200 Subject: [PATCH] bluez5: Make native and ofono backends optional --- config.h.meson | 6 ++++++ meson.build | 9 +++++++++ meson_options.txt | 8 ++++++++ spa/plugins/bluez5/defs.h | 22 ++++++++++++++++++++++ spa/plugins/bluez5/meson.build | 14 ++++++++++---- 5 files changed, 55 insertions(+), 4 deletions(-) diff --git a/config.h.meson b/config.h.meson index 3c6cf4bbb..3c0a699a3 100644 --- a/config.h.meson +++ b/config.h.meson @@ -320,6 +320,12 @@ /* for the systemd header files */ #mesondefine HAVE_SYSTEMD_DAEMON +/* Define to 1 if native HSP backend is enabled in bluez5 plugin. */ +#mesondefine HAVE_BLUEZ_5_BACKEND_NATIVE + +/* Define to 1 if oFono backend is enabled in bluez5 plugin. */ +#mesondefine HAVE_BLUEZ_5_BACKEND_OFONO + /* the host CPU */ #mesondefine HOST_CPU diff --git a/meson.build b/meson.build index bff13f262..668f5330c 100644 --- a/meson.build +++ b/meson.build @@ -254,6 +254,15 @@ if get_option('systemd') endif endif +if get_option('bluez5') + if get_option('bluez5-backend-native') + cdata.set('HAVE_BLUEZ_5_BACKEND_NATIVE', 1) + endif + if get_option('bluez5-backend-ofono') + cdata.set('HAVE_BLUEZ_5_BACKEND_OFONO', 1) + endif +endif + configure_file(input : 'config.h.meson', output : 'config.h', configuration : cdata) diff --git a/meson_options.txt b/meson_options.txt index 58830244d..e5f22818e 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -64,6 +64,14 @@ option('bluez5', description: 'Enable bluez5 spa plugin integration', type: 'boolean', value: true) +option('bluez5-backend-native', + description: 'Enable native HSP backend in bluez5 spa plugin', + type: 'boolean', + value: true) +option('bluez5-backend-ofono', + description: 'Enable oFono HFP backend in bluez5 spa plugin', + type: 'boolean', + value: true) option('control', description: 'Enable control spa plugin integration', type: 'boolean', diff --git a/spa/plugins/bluez5/defs.h b/spa/plugins/bluez5/defs.h index c133574aa..d1c4a7d2e 100644 --- a/spa/plugins/bluez5/defs.h +++ b/spa/plugins/bluez5/defs.h @@ -31,6 +31,8 @@ extern "C" { #include +#include "config.h" + #define BLUEZ_SERVICE "org.bluez" #define BLUEZ_PROFILE_MANAGER_INTERFACE BLUEZ_SERVICE ".ProfileManager1" #define BLUEZ_PROFILE_INTERFACE BLUEZ_SERVICE ".Profile1" @@ -295,17 +297,37 @@ static inline enum spa_bt_transport_state spa_bt_transport_state_from_string(con } +#ifdef HAVE_BLUEZ_5_BACKEND_NATIVE struct spa_bt_backend *backend_hsp_native_new(struct spa_bt_monitor *monitor, const struct spa_support *support, uint32_t n_support); void backend_hsp_native_free(struct spa_bt_backend *backend); void backend_hsp_native_register_profiles(struct spa_bt_backend *backend); +#else +static inline struct spa_bt_backend *backend_hsp_native_new(struct spa_bt_monitor *monitor, + const struct spa_support *support, + uint32_t n_support) { + return NULL; +} +static inline void backend_hsp_native_free(struct spa_bt_backend *backend) {} +static inline void backend_hsp_native_register_profiles(struct spa_bt_backend *backend) {} +#endif +#ifdef HAVE_BLUEZ_5_BACKEND_OFONO struct spa_bt_backend *backend_ofono_new(struct spa_bt_monitor *monitor, const struct spa_support *support, uint32_t n_support); void backend_ofono_free(struct spa_bt_backend *backend); void backend_ofono_add_filters(struct spa_bt_backend *backend); +#else +static inline struct spa_bt_backend *backend_ofono_new(struct spa_bt_monitor *monitor, + const struct spa_support *support, + uint32_t n_support) { + return NULL; +} +static inline void backend_ofono_free(struct spa_bt_backend *backend) {} +static inline void backend_ofono_add_filters(struct spa_bt_backend *backend) {} +#endif #ifdef __cplusplus } /* extern "C" */ diff --git a/spa/plugins/bluez5/meson.build b/spa/plugins/bluez5/meson.build index 70778c7c6..170f79e92 100644 --- a/spa/plugins/bluez5/meson.build +++ b/spa/plugins/bluez5/meson.build @@ -6,13 +6,19 @@ bluez5_sources = ['plugin.c', 'sco-sink.c', 'sco-source.c', 'bluez5-device.c', - 'bluez5-dbus.c', - 'backend-hsp-native.c', - 'backend-ofono.c'] + 'bluez5-dbus.c'] + +if get_option('bluez5-backend-native') + bluez5_sources += ['backend-hsp-native.c'] +endif + +if get_option('bluez5-backend-ofono') + bluez5_sources += ['backend-ofono.c'] +endif bluez5lib = shared_library('spa-bluez5', bluez5_sources, - include_directories : [ spa_inc ], + include_directories : [ spa_inc, configinc ], c_args : [ '-D_GNU_SOURCE' ], dependencies : [ dbus_dep, sbc_dep, bluez_dep ], install : true,