Commit d737263c authored by pali's avatar pali
Browse files

bluetooth: Rename native backend to legacy_hsp

It is really legacy code which supports only HSP profile. Also handling of
master SCO socket in AG role is broken.
parent a27ee27a
......@@ -1099,16 +1099,16 @@ AM_CONDITIONAL([HAVE_BLUEZ], [test "x$HAVE_BLUEZ" = x1])
## Bluetooth Headset profiles backend ##
AC_ARG_ENABLE([bluez5-native-headset],
AS_HELP_STRING([--disable-bluez5-native-headset],[Disable optional native headset backend support (Bluez 5)]))
AS_IF([test "x$HAVE_BLUEZ_5" = "x1" && test "x$enable_bluez5_native_headset" != "xno"],
[PKG_CHECK_MODULES(BLUEZ, [ bluez >= 4.101 ], HAVE_BLUEZ_5_NATIVE_HEADSET=1, HAVE_BLUEZ_5_NATIVE_HEADSET=0)],
HAVE_BLUEZ_5_NATIVE_HEADSET=0)
AS_IF([test "x$enable_bluez5_native_headset" = "xyes" && test "x$HAVE_BLUEZ_5_NATIVE_HEADSET" = "x0"],
[AC_MSG_ERROR([*** BlueZ 5 native headset backend support not available (requires the libbluetooth headers)])])
AC_SUBST(HAVE_BLUEZ_5_NATIVE_HEADSET)
AM_CONDITIONAL([HAVE_BLUEZ_5_NATIVE_HEADSET], [test "x$HAVE_BLUEZ_5_NATIVE_HEADSET" = x1])
AS_IF([test "x$HAVE_BLUEZ_5_NATIVE_HEADSET" = "x1"], AC_DEFINE([HAVE_BLUEZ_5_NATIVE_HEADSET], 1, [Bluez 5 native headset backend enabled]))
AC_ARG_ENABLE([bluez5-legacy-hsp],
AS_HELP_STRING([--disable-bluez5-legacy-hsp],[Disable optional legacy HSP backend support (Bluez 5)]))
AS_IF([test "x$HAVE_BLUEZ_5" = "x1" && test "x$enable_bluez5_legacy_hsp" != "xno"],
[PKG_CHECK_MODULES(BLUEZ, [ bluez >= 4.101 ], HAVE_BLUEZ_5_LEGACY_HSP=1, HAVE_BLUEZ_5_LEGACY_HSP=0)],
HAVE_BLUEZ_5_LEGACY_HSP=0)
AS_IF([test "x$enable_bluez5_legacy_hsp" = "xyes" && test "x$HAVE_BLUEZ_5_LEGACY_HSP" = "x0"],
[AC_MSG_ERROR([*** BlueZ 5 legacy HSP backend support not available (requires the libbluetooth headers)])])
AC_SUBST(HAVE_BLUEZ_5_LEGACY_HSP)
AM_CONDITIONAL([HAVE_BLUEZ_5_LEGACY_HSP], [test "x$HAVE_BLUEZ_5_LEGACY_HSP" = x1])
AS_IF([test "x$HAVE_BLUEZ_5_LEGACY_HSP" = "x1"], AC_DEFINE([HAVE_BLUEZ_5_LEGACY_HSP], 1, [Bluez 5 legacy HSP backend enabled]))
#### Bluetooth A2DP aptX codec (optional) ###
......@@ -1643,7 +1643,7 @@ AS_IF([test "x$HAVE_SYSTEMD_DAEMON" = "x1"], ENABLE_SYSTEMD_DAEMON=yes, ENABLE_S
AS_IF([test "x$HAVE_SYSTEMD_LOGIN" = "x1"], ENABLE_SYSTEMD_LOGIN=yes, ENABLE_SYSTEMD_LOGIN=no)
AS_IF([test "x$HAVE_SYSTEMD_JOURNAL" = "x1"], ENABLE_SYSTEMD_JOURNAL=yes, ENABLE_SYSTEMD_JOURNAL=no)
AS_IF([test "x$HAVE_BLUEZ_5" = "x1"], ENABLE_BLUEZ_5=yes, ENABLE_BLUEZ_5=no)
AS_IF([test "x$HAVE_BLUEZ_5_NATIVE_HEADSET" = "x1"], ENABLE_BLUEZ_5_NATIVE_HEADSET=yes, ENABLE_BLUEZ_5_NATIVE_HEADSET=no)
AS_IF([test "x$HAVE_BLUEZ_5_LEGACY_HSP" = "x1"], ENABLE_BLUEZ_5_LEGACY_HSP=yes, ENABLE_BLUEZ_5_LEGACY_HSP=no)
AS_IF([test "x$HAVE_OPENAPTX" = "x1"], ENABLE_APTX=yes, ENABLE_APTX=no)
AS_IF([test "x$HAVE_HAL_COMPAT" = "x1"], ENABLE_HAL_COMPAT=yes, ENABLE_HAL_COMPAT=no)
AS_IF([test "x$HAVE_TCPWRAP" = "x1"], ENABLE_TCPWRAP=yes, ENABLE_TCPWRAP=no)
......@@ -1702,7 +1702,7 @@ echo "
Enable LIRC: ${ENABLE_LIRC}
Enable D-Bus: ${ENABLE_DBUS}
Enable BlueZ 5: ${ENABLE_BLUEZ_5}
Enable native headsets: ${ENABLE_BLUEZ_5_NATIVE_HEADSET}
Enable legacy HSP backend: ${ENABLE_BLUEZ_5_LEGACY_HSP}
Enable aptX+aptXHD codecs: ${ENABLE_APTX}
Enable udev: ${ENABLE_UDEV}
Enable HAL->udev compat: ${ENABLE_HAL_COMPAT}
......
......@@ -626,8 +626,8 @@ if get_option('bluez5')
cdata.set('HAVE_SBC', 1)
cdata.set('HAVE_BLUEZ', 1)
cdata.set('HAVE_BLUEZ_5', 1)
if get_option('bluez5-native-headset')
cdata.set('HAVE_BLUEZ_5_NATIVE_HEADSET', 1)
if get_option('bluez5-legacy-hsp')
cdata.set('HAVE_BLUEZ_5_LEGACY_HSP', 1)
endif
endif
......@@ -818,7 +818,7 @@ summary = [
'Enable LIRC: @0@'.format(lirc_dep.found()),
'Enable D-Bus: @0@'.format(dbus_dep.found()),
' Enable BlueZ 5: @0@'.format(get_option('bluez5')),
' Enable native headsets: @0@'.format(get_option('bluez5-native-headset')),
' Enable legacy HSP backend: @0@'.format(get_option('bluez5-legacy-hsp')),
' Enable aptX+aptXHD codecs: @0@'.format(bluez5_aptx),
'Enable udev: @0@'.format(udev_dep.found()),
' Enable HAL->udev compat: @0@'.format(get_option('hal-compat')),
......
......@@ -78,9 +78,9 @@ option('bluez5',
option('bluez5-aptx',
type : 'feature', value : 'auto',
description : 'Optional aptX support')
option('bluez5-native-headset',
option('bluez5-legacy-hsp',
type : 'boolean',
description : 'Optional native headset backend support (BlueZ 5)')
description : 'Optional legacy HSP backend support (BlueZ 5)')
option('dbus',
type : 'feature', value : 'auto',
description : 'Optional D-Bus support')
......
......@@ -2154,9 +2154,9 @@ libbluez5_util_la_SOURCES = \
modules/bluetooth/a2dp-codec-util.h \
modules/bluetooth/a2dp-codecs.h \
modules/bluetooth/rtp.h
if HAVE_BLUEZ_5_NATIVE_HEADSET
if HAVE_BLUEZ_5_LEGACY_HSP
libbluez5_util_la_SOURCES += \
modules/bluetooth/backend-native.c
modules/bluetooth/legacy-hsp.c
endif
libbluez5_util_la_LDFLAGS = -avoid-version
......
......@@ -118,7 +118,7 @@ struct pa_bluetooth_discovery {
pa_hashmap *transports;
int headset_backend;
pa_bluetooth_backend *native_backend;
pa_bluetooth_backend *legacy_hsp_backend;
PA_LLIST_HEAD(pa_dbus_pending, pending);
};
......@@ -1374,8 +1374,8 @@ static void get_managed_objects_reply(DBusPendingCall *pending, void *userdata)
y->objects_listed = true;
if (!y->native_backend && (y->headset_backend == HEADSET_BACKEND_AUTO || y->headset_backend == HEADSET_BACKEND_NATIVE))
y->native_backend = pa_bluetooth_native_backend_new(y->core, y, (y->headset_backend == HEADSET_BACKEND_NATIVE));
if (!y->legacy_hsp_backend && (y->headset_backend == HEADSET_BACKEND_AUTO || y->headset_backend == HEADSET_BACKEND_LEGACY_HSP))
y->legacy_hsp_backend = pa_bluetooth_legacy_hsp_backend_new(y->core, y, (y->headset_backend == HEADSET_BACKEND_LEGACY_HSP));
finish:
dbus_message_unref(r);
......@@ -1429,9 +1429,9 @@ static DBusHandlerResult filter_cb(DBusConnection *bus, DBusMessage *m, void *us
pa_hashmap_remove_all(y->devices);
pa_hashmap_remove_all(y->adapters);
y->objects_listed = false;
if (y->native_backend) {
pa_bluetooth_native_backend_free(y->native_backend);
y->native_backend = NULL;
if (y->legacy_hsp_backend) {
pa_bluetooth_legacy_hsp_backend_free(y->legacy_hsp_backend);
y->legacy_hsp_backend = NULL;
}
}
......@@ -2398,8 +2398,8 @@ void pa_bluetooth_discovery_unref(pa_bluetooth_discovery *y) {
pa_dbus_free_pending_list(&y->pending);
if (y->native_backend)
pa_bluetooth_native_backend_free(y->native_backend);
if (y->legacy_hsp_backend)
pa_bluetooth_legacy_hsp_backend_free(y->legacy_hsp_backend);
if (y->adapters)
pa_hashmap_free(y->adapters);
......
......@@ -132,16 +132,16 @@ struct pa_bluetooth_adapter {
bool media_application_registered;
};
#ifdef HAVE_BLUEZ_5_NATIVE_HEADSET
pa_bluetooth_backend *pa_bluetooth_native_backend_new(pa_core *c, pa_bluetooth_discovery *y, bool enable_hs_role);
void pa_bluetooth_native_backend_free(pa_bluetooth_backend *b);
void pa_bluetooth_native_backend_enable_hs_role(pa_bluetooth_backend *b, bool enable_hs_role);
#ifdef HAVE_BLUEZ_5_LEGACY_HSP
pa_bluetooth_backend *pa_bluetooth_legacy_hsp_backend_new(pa_core *c, pa_bluetooth_discovery *y, bool enable_hs_role);
void pa_bluetooth_legacy_hsp_backend_free(pa_bluetooth_backend *b);
void pa_bluetooth_legacy_hsp_backend_enable_hs_role(pa_bluetooth_backend *b, bool enable_hs_role);
#else
static inline pa_bluetooth_backend *pa_bluetooth_native_backend_new(pa_core *c, pa_bluetooth_discovery *y, bool enable_hs_role) {
static inline pa_bluetooth_backend *pa_bluetooth_legacy_hsp_backend_new(pa_core *c, pa_bluetooth_discovery *y, bool enable_hs_role) {
return NULL;
}
static inline void pa_bluetooth_native_backend_free(pa_bluetooth_backend *b) {}
static inline void pa_bluetooth_native_backend_enable_hs_role(pa_bluetooth_backend *b, bool enable_hs_role) {}
static inline void pa_bluetooth_legacy_hsp_backend_free(pa_bluetooth_backend *b) {}
static inline void pa_bluetooth_legacy_hsp_backend_enable_hs_role(pa_bluetooth_backend *b, bool enable_hs_role) {}
#endif
pa_bluetooth_transport *pa_bluetooth_transport_new(pa_bluetooth_device *d, const char *owner, const char *path,
......@@ -181,7 +181,7 @@ static inline bool pa_bluetooth_uuid_is_hsp_hs(const char *uuid) {
return pa_streq(uuid, PA_BLUETOOTH_UUID_HSP_HS) || pa_streq(uuid, PA_BLUETOOTH_UUID_HSP_HS_ALT);
}
#define HEADSET_BACKEND_NATIVE 1
#define HEADSET_BACKEND_LEGACY_HSP 1
#define HEADSET_BACKEND_AUTO 2
pa_bluetooth_discovery* pa_bluetooth_discovery_get(pa_core *core, int headset_backend);
......
......@@ -659,24 +659,24 @@ static void profile_done(pa_bluetooth_backend *b, pa_bluetooth_profile_t profile
}
}
void pa_bluetooth_native_backend_enable_hs_role(pa_bluetooth_backend *native_backend, bool enable_hs_role) {
void pa_bluetooth_legacy_hsp_backend_enable_hs_role(pa_bluetooth_backend *legacy_hsp_backend, bool enable_hs_role) {
if (enable_hs_role == native_backend->enable_hs_role)
if (enable_hs_role == legacy_hsp_backend->enable_hs_role)
return;
if (enable_hs_role)
profile_init(native_backend, PA_BLUETOOTH_PROFILE_HEADSET_AUDIO_GATEWAY);
profile_init(legacy_hsp_backend, PA_BLUETOOTH_PROFILE_HEADSET_AUDIO_GATEWAY);
else
profile_done(native_backend, PA_BLUETOOTH_PROFILE_HEADSET_AUDIO_GATEWAY);
profile_done(legacy_hsp_backend, PA_BLUETOOTH_PROFILE_HEADSET_AUDIO_GATEWAY);
native_backend->enable_hs_role = enable_hs_role;
legacy_hsp_backend->enable_hs_role = enable_hs_role;
}
pa_bluetooth_backend *pa_bluetooth_native_backend_new(pa_core *c, pa_bluetooth_discovery *y, bool enable_hs_role) {
pa_bluetooth_backend *pa_bluetooth_legacy_hsp_backend_new(pa_core *c, pa_bluetooth_discovery *y, bool enable_hs_role) {
pa_bluetooth_backend *backend;
DBusError err;
pa_log_debug("Bluetooth Headset Backend API support using the native backend");
pa_log_debug("Bluetooth Headset Backend API support using the legacy HSP backend");
backend = pa_xnew0(pa_bluetooth_backend, 1);
backend->core = c;
......@@ -699,7 +699,7 @@ pa_bluetooth_backend *pa_bluetooth_native_backend_new(pa_core *c, pa_bluetooth_d
return backend;
}
void pa_bluetooth_native_backend_free(pa_bluetooth_backend *backend) {
void pa_bluetooth_legacy_hsp_backend_free(pa_bluetooth_backend *backend) {
pa_assert(backend);
pa_dbus_free_pending_list(&backend->pending);
......
......@@ -13,8 +13,8 @@ libbluez5_util_headers = [
'rtp.h',
]
if get_option('bluez5-native-headset')
libbluez5_util_sources += [ 'backend-native.c' ]
if get_option('bluez5-legacy-hsp')
libbluez5_util_sources += [ 'legacy-hsp.c' ]
endif
if bluez5_aptx
......
......@@ -30,7 +30,7 @@ PA_MODULE_DESCRIPTION("Detect available Bluetooth daemon and load the correspond
PA_MODULE_VERSION(PACKAGE_VERSION);
PA_MODULE_LOAD_ONCE(true);
PA_MODULE_USAGE(
"headset=native|auto"
"headset=legacy_hsp|auto"
"autodetect_mtu=<boolean>"
);
......
......@@ -35,7 +35,7 @@ PA_MODULE_DESCRIPTION("Detect available BlueZ 5 Bluetooth audio devices and load
PA_MODULE_VERSION(PACKAGE_VERSION);
PA_MODULE_LOAD_ONCE(true);
PA_MODULE_USAGE(
"headset=native|auto"
"headset=legacy_hsp|auto"
"autodetect_mtu=<boolean>"
);
......@@ -109,12 +109,13 @@ int pa__init(pa_module *m) {
}
pa_assert_se(headset_str = pa_modargs_get_value(ma, "headset", default_headset_backend));
if (pa_streq(headset_str, "native"))
headset_backend = HEADSET_BACKEND_NATIVE;
/* For backward compatibility we also support "native" as alias for "legacy_hsp" */
if (pa_streq(headset_str, "native") || pa_streq(headset_str, "legacy_hsp"))
headset_backend = HEADSET_BACKEND_LEGACY_HSP;
else if (pa_streq(headset_str, "auto"))
headset_backend = HEADSET_BACKEND_AUTO;
else {
pa_log("headset parameter must be either native or auto (found %s)", headset_str);
pa_log("headset parameter must be either legacy_hsp or auto (found %s)", headset_str);
goto fail;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment