bluez5: Make native and ofono backends optional

This commit is contained in:
Frédéric Danis 2020-07-22 14:50:38 +02:00 committed by Wim Taymans
parent ebdaac160c
commit db0c224b06
5 changed files with 55 additions and 4 deletions

View File

@ -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

View File

@ -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)

View File

@ -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',

View File

@ -31,6 +31,8 @@ extern "C" {
#include <spa/utils/hook.h>
#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" */

View File

@ -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,