Commit c95129bd authored by pali's avatar pali
Browse files

bluetooth: Simplify hsphfpd and legacy HSP profile implementation and registration

Coexistence between them is not fully working, so always use automatic mode
between choosing them. Create proper type for hsphpfd and legacy hsp
structures, change variable names to reflect state. And also move functions
into own header files.
parent c4cea2af
......@@ -2148,8 +2148,10 @@ module_bluetooth_discover_la_CFLAGS = $(AM_CFLAGS) -DPA_MODULE_NAME=module_bluet
# Bluetooth BlueZ 5 sink / source
libbluez5_util_la_SOURCES = \
modules/bluetooth/hsphfpd-util.c \
modules/bluetooth/hsphfpd-util.h \
modules/bluetooth/bluez5-util.c \
modules/bluetooth/bluez5-util.h \
modules/bluetooth/legacy-hsp.h \
modules/bluetooth/a2dp-codec-api.h \
modules/bluetooth/a2dp-codec-util.c \
modules/bluetooth/a2dp-codec-util.h \
......
......@@ -40,6 +40,7 @@
#include "a2dp-codecs.h"
#include "bluez5-util.h"
#include "hsphfpd-util.h"
#define WAIT_FOR_PROFILES_TIMEOUT_USEC (3 * PA_USEC_PER_SEC)
......@@ -119,10 +120,7 @@ struct pa_bluetooth_discovery {
pa_hashmap *devices;
pa_hashmap *transports;
pa_hashmap *pending_transport_fds;
int headset_backend;
pa_bluetooth_backend *hsphfpd_backend;
pa_bluetooth_backend *legacy_hsp_backend;
pa_bluetooth_hsphfpd *hsphfpd;
PA_LLIST_HEAD(pa_dbus_pending, pending);
};
......@@ -1456,13 +1454,6 @@ static void parse_interfaces_and_properties(pa_bluetooth_discovery *y, DBusMessa
return;
}
/* This function may be called only by hsphfpd backend.
Legacy HSP backend may be enabled only when hsphfpd daemon is not running. */
void pa_bluetooth_discovery_legacy_hsp_backend_enable(pa_bluetooth_discovery *y, bool enable) {
if (y->legacy_hsp_backend)
pa_bluetooth_legacy_hsp_backend_enable(y->legacy_hsp_backend, enable);
}
static void get_managed_objects_reply(DBusPendingCall *pending, void *userdata) {
pa_dbus_pending *p;
pa_bluetooth_discovery *y;
......@@ -1501,11 +1492,8 @@ static void get_managed_objects_reply(DBusPendingCall *pending, void *userdata)
y->objects_listed = true;
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));
if (!y->hsphfpd_backend && (y->headset_backend == HEADSET_BACKEND_AUTO || y->headset_backend == HEADSET_BACKEND_HSPHFPD))
y->hsphfpd_backend = pa_bluetooth_hsphfpd_backend_new(y->core, y);
if (!y->hsphfpd)
y->hsphfpd = pa_bluetooth_hsphfpd_new(y->core, y);
finish:
dbus_message_unref(r);
......@@ -1559,13 +1547,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->hsphfpd_backend) {
pa_bluetooth_hsphfpd_backend_free(y->hsphfpd_backend);
y->hsphfpd_backend = NULL;
}
if (y->legacy_hsp_backend) {
pa_bluetooth_legacy_hsp_backend_free(y->legacy_hsp_backend);
y->legacy_hsp_backend = NULL;
if (y->hsphfpd) {
pa_bluetooth_hsphfpd_free(y->hsphfpd);
y->hsphfpd = NULL;
}
}
......@@ -2557,7 +2541,7 @@ static void object_manager_done(pa_bluetooth_discovery *y) {
dbus_connection_unregister_object_path(pa_dbus_connection_get(y->connection), A2DP_OBJECT_MANAGER_PATH);
}
pa_bluetooth_discovery* pa_bluetooth_discovery_get(pa_core *c, int headset_backend) {
pa_bluetooth_discovery* pa_bluetooth_discovery_get(pa_core *c) {
pa_bluetooth_discovery *y;
DBusError err;
DBusConnection *conn;
......@@ -2568,7 +2552,6 @@ pa_bluetooth_discovery* pa_bluetooth_discovery_get(pa_core *c, int headset_backe
y = pa_xnew0(pa_bluetooth_discovery, 1);
PA_REFCNT_INIT(y);
y->core = c;
y->headset_backend = headset_backend;
y->adapters = pa_hashmap_new_full(pa_idxset_string_hash_func, pa_idxset_string_compare_func, NULL,
(pa_free_cb_t) adapter_free);
y->devices = pa_hashmap_new_full(pa_idxset_string_hash_func, pa_idxset_string_compare_func, NULL,
......@@ -2667,11 +2650,8 @@ void pa_bluetooth_discovery_unref(pa_bluetooth_discovery *y) {
pa_dbus_free_pending_list(&y->pending);
if (y->hsphfpd_backend)
pa_bluetooth_hsphfpd_backend_free(y->hsphfpd_backend);
if (y->legacy_hsp_backend)
pa_bluetooth_legacy_hsp_backend_free(y->legacy_hsp_backend);
if (y->hsphfpd)
pa_bluetooth_hsphfpd_free(y->hsphfpd);
if (y->pending_transport_fds)
pa_hashmap_free(y->pending_transport_fds);
......
......@@ -43,7 +43,6 @@ typedef struct pa_bluetooth_transport pa_bluetooth_transport;
typedef struct pa_bluetooth_device pa_bluetooth_device;
typedef struct pa_bluetooth_adapter pa_bluetooth_adapter;
typedef struct pa_bluetooth_discovery pa_bluetooth_discovery;
typedef struct pa_bluetooth_backend pa_bluetooth_backend;
typedef enum pa_bluetooth_hook {
PA_BLUETOOTH_HOOK_DEVICE_CONNECTION_CHANGED, /* Call data: pa_bluetooth_device */
......@@ -144,21 +143,6 @@ struct pa_bluetooth_adapter {
bool media_application_registered;
};
pa_bluetooth_backend *pa_bluetooth_hsphfpd_backend_new(pa_core *c, pa_bluetooth_discovery *y);
void pa_bluetooth_hsphfpd_backend_free(pa_bluetooth_backend *b);
#ifdef HAVE_BLUEZ_5_LEGACY_HSP
pa_bluetooth_backend *pa_bluetooth_legacy_hsp_backend_new(pa_core *c, pa_bluetooth_discovery *y, bool enable);
void pa_bluetooth_legacy_hsp_backend_free(pa_bluetooth_backend *b);
void pa_bluetooth_legacy_hsp_backend_enable(pa_bluetooth_backend *b, bool enable);
#else
static inline pa_bluetooth_backend *pa_bluetooth_legacy_hsp_backend_new(pa_core *c, pa_bluetooth_discovery *y, bool enable) {
return NULL;
}
static inline void pa_bluetooth_legacy_hsp_backend_free(pa_bluetooth_backend *b) {}
static inline void pa_bluetooth_legacy_hsp_backend_enable(pa_bluetooth_backend *b, bool enable) {}
#endif
pa_bluetooth_transport *pa_bluetooth_transport_new(pa_bluetooth_device *d, const char *owner, const char *path,
pa_bluetooth_profile_t p, const uint8_t *config, size_t size);
......@@ -202,12 +186,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_HSPHFPD 0
#define HEADSET_BACKEND_LEGACY_HSP 1
#define HEADSET_BACKEND_AUTO 2
pa_bluetooth_discovery* pa_bluetooth_discovery_get(pa_core *core, int headset_backend);
pa_bluetooth_discovery* pa_bluetooth_discovery_get(pa_core *core);
pa_bluetooth_discovery* pa_bluetooth_discovery_ref(pa_bluetooth_discovery *y);
void pa_bluetooth_discovery_unref(pa_bluetooth_discovery *y);
void pa_bluetooth_discovery_legacy_hsp_backend_enable(pa_bluetooth_discovery *y, bool enable);
#endif
This diff is collapsed.
#ifndef foohsphfpdutilhfoo
#define foohsphfpdutilhfoo
/***
This file is part of PulseAudio.
Copyrigth 2020 Pali Rohár <pali.rohar@gmail.com>
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
PulseAudio 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 Lesser General Public
License along with PulseAudio; if not, see <http://www.gnu.org/licenses/>.
***/
#include <pulsecore/core.h>
typedef struct pa_bluetooth_hsphfpd pa_bluetooth_hsphfpd;
pa_bluetooth_hsphfpd *pa_bluetooth_hsphfpd_new(pa_core *core, pa_bluetooth_discovery *discovery);
void pa_bluetooth_hsphfpd_free(pa_bluetooth_hsphfpd *hsphfpd);
#endif
......@@ -35,12 +35,12 @@
#include <bluetooth/sco.h>
#include "bluez5-util.h"
#include "legacy-hsp.h"
struct pa_bluetooth_backend {
struct pa_bluetooth_legacy_hsp {
pa_core *core;
pa_dbus_connection *connection;
pa_bluetooth_discovery *discovery;
bool enabled;
char *service_id;
PA_LLIST_HEAD(pa_dbus_pending, pending);
......@@ -86,19 +86,19 @@ struct transport_data {
" </interface>" \
"</node>"
static pa_dbus_pending* send_and_add_to_pending(pa_bluetooth_backend *backend, DBusMessage *m,
static pa_dbus_pending* send_and_add_to_pending(pa_bluetooth_legacy_hsp *hsp, DBusMessage *m,
DBusPendingCallNotifyFunction func, void *call_data) {
pa_dbus_pending *p;
DBusPendingCall *call;
pa_assert(backend);
pa_assert(hsp);
pa_assert(m);
pa_assert_se(dbus_connection_send_with_reply(pa_dbus_connection_get(backend->connection), m, &call, -1));
pa_assert_se(dbus_connection_send_with_reply(pa_dbus_connection_get(hsp->connection), m, &call, -1));
p = pa_dbus_pending_new(pa_dbus_connection_get(backend->connection), m, call, backend, call_data);
PA_LLIST_PREPEND(pa_dbus_pending, backend->pending, p);
p = pa_dbus_pending_new(pa_dbus_connection_get(hsp->connection), m, call, hsp, call_data);
PA_LLIST_PREPEND(pa_dbus_pending, hsp->pending, p);
dbus_pending_call_set_notify(call, func, p, NULL);
return p;
......@@ -260,11 +260,11 @@ static void sco_release_cb(pa_bluetooth_transport *t) {
static void register_profile_reply(DBusPendingCall *pending, void *userdata) {
DBusMessage *r;
pa_dbus_pending *p;
pa_bluetooth_backend *b;
pa_bluetooth_legacy_hsp *hsp;
pa_assert(pending);
pa_assert_se(p = userdata);
pa_assert_se(b = p->context_data);
pa_assert_se(hsp = p->context_data);
pa_assert_se(r = dbus_pending_call_steal_reply(pending));
if (dbus_message_is_error(r, BLUEZ_ERROR_NOT_SUPPORTED)) {
......@@ -278,16 +278,16 @@ static void register_profile_reply(DBusPendingCall *pending, void *userdata) {
goto finish;
}
b->service_id = pa_xstrdup(dbus_message_get_sender(r));
hsp->service_id = pa_xstrdup(dbus_message_get_sender(r));
finish:
dbus_message_unref(r);
PA_LLIST_REMOVE(pa_dbus_pending, b->pending, p);
PA_LLIST_REMOVE(pa_dbus_pending, hsp->pending, p);
pa_dbus_pending_free(p);
}
static void register_profile(pa_bluetooth_backend *b) {
static void register_profile(pa_bluetooth_legacy_hsp *hsp) {
DBusMessage *m;
DBusMessageIter i, d;
const char *object = HSP_AG_PROFILE;
......@@ -304,10 +304,10 @@ static void register_profile(pa_bluetooth_backend *b) {
DBUS_TYPE_VARIANT_AS_STRING DBUS_DICT_ENTRY_END_CHAR_AS_STRING, &d);
dbus_message_iter_close_container(&i, &d);
send_and_add_to_pending(b, m, register_profile_reply, NULL);
send_and_add_to_pending(hsp, m, register_profile_reply, NULL);
}
static void unregister_profile(pa_bluetooth_backend *b) {
static void unregister_profile(pa_bluetooth_legacy_hsp *hsp) {
DBusMessage *m;
const char *object = HSP_AG_PROFILE;
pa_hashmap *transports;
......@@ -318,12 +318,12 @@ static void unregister_profile(pa_bluetooth_backend *b) {
pa_assert_se(m = dbus_message_new_method_call(BLUEZ_SERVICE, "/org/bluez", BLUEZ_PROFILE_MANAGER_INTERFACE, "UnregisterProfile"));
pa_assert_se(dbus_message_append_args(m, DBUS_TYPE_OBJECT_PATH, &object, DBUS_TYPE_INVALID));
pa_assert_se(dbus_connection_send(pa_dbus_connection_get(b->connection), m, NULL));
pa_assert_se(dbus_connection_send(pa_dbus_connection_get(hsp->connection), m, NULL));
pa_assert_se(transports = pa_bluetooth_transport_get_all(b->discovery));
pa_assert_se(transports = pa_bluetooth_transport_get_all(hsp->discovery));
PA_HASHMAP_FOREACH(t, transports, state) {
/* owner for legacy HSP and A2DP is same bluez, so we need to check also for provide */
if (!t->owner || !pa_safe_streq(t->owner, b->service_id) || t->profile != PA_BLUETOOTH_PROFILE_HSP_HEAD_UNIT)
if (!t->owner || !pa_safe_streq(t->owner, hsp->service_id) || t->profile != PA_BLUETOOTH_PROFILE_HSP_HEAD_UNIT)
continue;
/* Function pa_bluetooth_transport_free() is safe as it just calls pa_hashmap_remove()
* on current iterator entry and this is by pulseaudio hashmap structure allowed */
......@@ -458,7 +458,7 @@ static void set_microphone_gain(pa_bluetooth_transport *t, uint16_t gain) {
}
static DBusMessage *profile_new_connection(DBusConnection *conn, DBusMessage *m, void *userdata) {
pa_bluetooth_backend *b = userdata;
pa_bluetooth_legacy_hsp *hsp = userdata;
pa_bluetooth_device *d;
pa_bluetooth_transport *t;
DBusMessage *r;
......@@ -483,7 +483,7 @@ static DBusMessage *profile_new_connection(DBusConnection *conn, DBusMessage *m,
pa_assert(dbus_message_iter_get_arg_type(&arg_i) == DBUS_TYPE_OBJECT_PATH);
dbus_message_iter_get_basic(&arg_i, &path);
d = pa_bluetooth_discovery_get_device_by_path(b->discovery, path);
d = pa_bluetooth_discovery_get_device_by_path(hsp->discovery, path);
if (d == NULL) {
pa_log_error("Device doesnt exist for %s", path);
pa_assert_se(r = dbus_message_new_error_printf(m, "org.bluez.Error.InvalidArguments", "Device doesnt exist for %s", path));
......@@ -515,8 +515,8 @@ static DBusMessage *profile_new_connection(DBusConnection *conn, DBusMessage *m,
trd = pa_xnew0(struct transport_data, 1);
trd->rfcomm_fd = fd;
trd->mainloop = b->core->mainloop;
trd->rfcomm_io = trd->mainloop->io_new(b->core->mainloop, fd, PA_IO_EVENT_INPUT,
trd->mainloop = hsp->core->mainloop;
trd->rfcomm_io = trd->mainloop->io_new(hsp->core->mainloop, fd, PA_IO_EVENT_INPUT,
rfcomm_io_callback, t);
trd->sco_fd = -EAGAIN;
t->userdata = trd;
......@@ -530,7 +530,7 @@ static DBusMessage *profile_new_connection(DBusConnection *conn, DBusMessage *m,
}
static DBusMessage *profile_request_disconnection(DBusConnection *conn, DBusMessage *m, void *userdata) {
pa_bluetooth_backend *b = userdata;
pa_bluetooth_legacy_hsp *hsp = userdata;
DBusMessage *r;
DBusError error;
const char *path;
......@@ -549,7 +549,7 @@ static DBusMessage *profile_request_disconnection(DBusConnection *conn, DBusMess
pa_log_debug("dbus: RequestDisconnection path=%s", path);
t = pa_bluetooth_transport_get(b->discovery, path);
t = pa_bluetooth_transport_get(hsp->discovery, path);
if (!t || !pa_safe_streq(dbus_message_get_sender(m), t->owner) || t->profile != PA_BLUETOOTH_PROFILE_HSP_HEAD_UNIT) {
pa_log_error("RequestDisconnection failed: Endpoint %s is not connected", path);
pa_assert_se(r = dbus_message_new_error_printf(m, "org.bluez.Error.InvalidArguments", "Endpoint %s is not connected", path));
......@@ -563,14 +563,11 @@ static DBusMessage *profile_request_disconnection(DBusConnection *conn, DBusMess
}
static DBusHandlerResult profile_handler(DBusConnection *c, DBusMessage *m, void *userdata) {
pa_bluetooth_backend *b = userdata;
pa_bluetooth_legacy_hsp *hsp = userdata;
DBusMessage *r = NULL;
const char *path, *interface, *member;
pa_assert(b);
if (!b->enabled)
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
pa_assert(hsp);
path = dbus_message_get_path(m);
interface = dbus_message_get_interface(m);
......@@ -598,80 +595,52 @@ static DBusHandlerResult profile_handler(DBusConnection *c, DBusMessage *m, void
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
if (r) {
pa_assert_se(dbus_connection_send(pa_dbus_connection_get(b->connection), r, NULL));
pa_assert_se(dbus_connection_send(pa_dbus_connection_get(hsp->connection), r, NULL));
dbus_message_unref(r);
}
return DBUS_HANDLER_RESULT_HANDLED;
}
static void profile_init(pa_bluetooth_backend *b) {
pa_bluetooth_legacy_hsp *pa_bluetooth_legacy_hsp_register(pa_core *c, pa_bluetooth_discovery *y) {
static const DBusObjectPathVTable vtable_profile = {
.message_function = profile_handler,
};
pa_assert(b);
pa_assert_se(dbus_connection_register_object_path(pa_dbus_connection_get(b->connection), HSP_AG_PROFILE, &vtable_profile, b));
register_profile(b);
}
static void profile_done(pa_bluetooth_backend *b) {
pa_assert(b);
unregister_profile(b);
pa_xfree(b->service_id);
b->service_id = NULL;
dbus_connection_unregister_object_path(pa_dbus_connection_get(b->connection), HSP_AG_PROFILE);
}
void pa_bluetooth_legacy_hsp_backend_enable(pa_bluetooth_backend *backend, bool enable) {
if (enable == backend->enabled)
return;
if (enable) {
pa_log_warn("Enabling legacy HSP backend");
profile_init(backend);
} else {
pa_log_warn("Disabling legacy HSP backend");
profile_done(backend);
}
backend->enabled = enable;
}
pa_bluetooth_backend *pa_bluetooth_legacy_hsp_backend_new(pa_core *c, pa_bluetooth_discovery *y, bool enable) {
pa_bluetooth_backend *backend;
pa_bluetooth_legacy_hsp *hsp;
DBusError err;
backend = pa_xnew0(pa_bluetooth_backend, 1);
backend->core = c;
pa_log_warn("Enabling legacy HSP profile");
hsp = pa_xnew0(pa_bluetooth_legacy_hsp, 1);
hsp->core = c;
dbus_error_init(&err);
if (!(backend->connection = pa_dbus_bus_get(c, DBUS_BUS_SYSTEM, &err))) {
if (!(hsp->connection = pa_dbus_bus_get(c, DBUS_BUS_SYSTEM, &err))) {
pa_log("Failed to get D-Bus connection: %s", err.message);
dbus_error_free(&err);
pa_xfree(backend);
pa_xfree(hsp);
return NULL;
}
backend->discovery = y;
backend->enabled = enable;
if (enable)
profile_init(backend);
hsp->discovery = y;
return backend;
pa_assert_se(dbus_connection_register_object_path(pa_dbus_connection_get(hsp->connection), HSP_AG_PROFILE, &vtable_profile, hsp));
register_profile(hsp);
return hsp;
}
void pa_bluetooth_legacy_hsp_backend_free(pa_bluetooth_backend *backend) {
pa_assert(backend);
void pa_bluetooth_legacy_hsp_unregister(pa_bluetooth_legacy_hsp *hsp) {
pa_assert(hsp);
pa_dbus_free_pending_list(&backend->pending);
pa_log_warn("Disabling legacy HSP profile");
if (backend->enabled)
profile_done(backend);
pa_dbus_free_pending_list(&hsp->pending);
pa_dbus_connection_unref(backend->connection);
unregister_profile(hsp);
dbus_connection_unregister_object_path(pa_dbus_connection_get(hsp->connection), HSP_AG_PROFILE);
pa_dbus_connection_unref(hsp->connection);
pa_xfree(backend);
pa_xfree(hsp->service_id);
pa_xfree(hsp);
}
#ifndef foolegacyhsphfoo
#define foolegacyhsphfoo
/***
This file is part of PulseAudio.
Copyrigth 2020 Pali Rohár <pali.rohar@gmail.com>
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
PulseAudio 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 Lesser General Public
License along with PulseAudio; if not, see <http://www.gnu.org/licenses/>.
***/
#include <pulsecore/core.h>
typedef struct pa_bluetooth_legacy_hsp pa_bluetooth_legacy_hsp;
#ifdef HAVE_BLUEZ_5_LEGACY_HSP
pa_bluetooth_legacy_hsp *pa_bluetooth_legacy_hsp_register(pa_core *c, pa_bluetooth_discovery *y);
void pa_bluetooth_legacy_hsp_unregister(pa_bluetooth_legacy_hsp *hsp);
#else
static inline pa_bluetooth_legacy_hsp *pa_bluetooth_legacy_hsp_register(pa_core *c, pa_bluetooth_discovery *y) { return NULL; }
static inline void pa_bluetooth_legacy_hsp_unregister(pa_bluetooth_legacy_hsp *hsp) {}
#endif
#endif
......@@ -11,6 +11,8 @@ libbluez5_util_headers = [
'a2dp-codecs.h',
'a2dp-codec-util.h',
'bluez5-util.h',
'hsphfpd-util.h',
'legacy-hsp.h',
'rtp.h',
]
......
......@@ -30,7 +30,6 @@ 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=auto|hsphfpd|legacy_hsp"
"autodetect_mtu=<boolean>"
);
......
......@@ -35,12 +35,10 @@ 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=auto|hsphfpd|legacy_hsp"
"autodetect_mtu=<boolean>"
);
static const char* const valid_modargs[] = {
"headset",
"autodetect_mtu",
NULL
};
......@@ -95,8 +93,6 @@ static pa_hook_result_t device_connection_changed_cb(pa_bluetooth_discovery *y,
int pa__init(pa_module *m) {
struct userdata *u;
pa_modargs *ma;
const char *headset_str;
int headset_backend;
bool autodetect_mtu;
pa_assert(m);
......@@ -106,25 +102,6 @@ int pa__init(pa_module *m) {
goto fail;
}
pa_assert_se(headset_str = pa_modargs_get_value(ma, "headset", "auto"));
if (pa_streq(headset_str, "hsphfpd"))
headset_backend = HEADSET_BACKEND_HSPHFPD;
#ifdef HAVE_BLUEZ_5_LEGACY_HSP
/* For backward compatibility we also support "native" as alias for "legacy_hsp" */
else if (pa_streq(headset_str, "native") || pa_streq(headset_str, "legacy_hsp"))
headset_backend = HEADSET_BACKEND_LEGACY_HSP;
#endif
else if (pa_streq(headset_str, "auto"))
headset_backend = HEADSET_BACKEND_AUTO;
else {
pa_log("headset parameter must be either hsphfpd"
#ifdef HAVE_BLUEZ_5_LEGACY_HSP
", legacy_hsp"
#endif
" or auto (found %s)", headset_str);
goto fail;
}
autodetect_mtu = false;
if (pa_modargs_get_value_boolean(ma, "autodetect_mtu", &autodetect_mtu) < 0) {
pa_log("Invalid boolean value for autodetect_mtu parameter");
......@@ -137,7 +114,7 @@ int pa__init(pa_module *m) {
u->autodetect_mtu = autodetect_mtu;
u->loaded_device_paths = pa_hashmap_new(pa_idxset_string_hash_func, pa_idxset_string_compare_func);
if (!(u->discovery = pa_bluetooth_discovery_get(u->core, headset_backend)))
if (!(u->discovery = pa_bluetooth_discovery_get(u->core)))
goto fail;
u->device_connection_changed_slot =
......
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