[pulseaudio-discuss] [PATCH] Unconditionally load both bluetooth headset backends
Georg Chini
georg at chini.tk
Mon Feb 2 12:51:02 PST 2015
Unconditionally load both bluetooth headset backends as they do not interfer. Ofono only
supports the HFP HF role while the native backend only supports HSP AG. If there is an
active modem in your system ofono registers UUID 111f while the native backend registers
UUID 1112, so there is no need to disable the native backend when ofono is running. The
headset will then just connect to ofono instead of pulse. If you run ofono with
--noplugin=hfp_ag_bluez5, ofono will not register UUID 111f and the headset will always
connect to pulse.
---
src/modules/bluetooth/backend-ofono.c | 3 --
src/modules/bluetooth/bluez5-util.c | 25 ++---------------
src/modules/bluetooth/bluez5-util.h | 3 +-
src/modules/bluetooth/module-bluez5-discover.c | 38 +-------------------------
4 files changed, 5 insertions(+), 64 deletions(-)
diff --git a/src/modules/bluetooth/backend-ofono.c b/src/modules/bluetooth/backend-ofono.c
index 755df9e..9ed255b 100644
--- a/src/modules/bluetooth/backend-ofono.c
+++ b/src/modules/bluetooth/backend-ofono.c
@@ -340,7 +340,6 @@ static void ofono_bus_id_destroy(pa_bluetooth_backend *backend) {
if (backend->ofono_bus_id) {
pa_xfree(backend->ofono_bus_id);
backend->ofono_bus_id = NULL;
- pa_bluetooth_discovery_set_ofono_running(backend->discovery, false);
}
}
@@ -368,8 +367,6 @@ finish:
PA_LLIST_REMOVE(pa_dbus_pending, backend->pending, p);
pa_dbus_pending_free(p);
-
- pa_bluetooth_discovery_set_ofono_running(backend->discovery, backend->ofono_bus_id != NULL);
}
static void hf_audio_agent_register(pa_bluetooth_backend *hf) {
diff --git a/src/modules/bluetooth/bluez5-util.c b/src/modules/bluetooth/bluez5-util.c
index 03c76bf..738bdee 100644
--- a/src/modules/bluetooth/bluez5-util.c
+++ b/src/modules/bluetooth/bluez5-util.c
@@ -85,7 +85,6 @@ struct pa_bluetooth_discovery {
pa_hashmap *devices;
pa_hashmap *transports;
- int headset_backend;
pa_bluetooth_backend *ofono_backend, *native_backend;
PA_LLIST_HEAD(pa_dbus_pending, pending);
};
@@ -860,21 +859,6 @@ static void parse_interfaces_and_properties(pa_bluetooth_discovery *y, DBusMessa
return;
}
-void pa_bluetooth_discovery_set_ofono_running(pa_bluetooth_discovery *y, bool is_running) {
- pa_assert(y);
-
- pa_log_debug("oFono is running: %s", pa_yes_no(is_running));
- if (y->headset_backend != HEADSET_BACKEND_AUTO)
- return;
-
- if (is_running && y->native_backend) {
- pa_bluetooth_native_backend_free(y->native_backend);
- y->native_backend = NULL;
- }
- else if (!is_running && !y->native_backend)
- y->native_backend = pa_bluetooth_native_backend_new(y->core, y);
-}
-
static void get_managed_objects_reply(DBusPendingCall *pending, void *userdata) {
pa_dbus_pending *p;
pa_bluetooth_discovery *y;
@@ -913,10 +897,8 @@ static void get_managed_objects_reply(DBusPendingCall *pending, void *userdata)
y->objects_listed = true;
- if (!y->ofono_backend && y->headset_backend != HEADSET_BACKEND_NATIVE)
- y->ofono_backend = pa_bluetooth_ofono_backend_new(y->core, y);
- if (!y->ofono_backend && !y->native_backend && y->headset_backend != HEADSET_BACKEND_OFONO)
- y->native_backend = pa_bluetooth_native_backend_new(y->core, y);
+ y->ofono_backend = pa_bluetooth_ofono_backend_new(y->core, y);
+ y->native_backend = pa_bluetooth_native_backend_new(y->core, y);
finish:
dbus_message_unref(r);
@@ -1570,7 +1552,7 @@ static void endpoint_done(pa_bluetooth_discovery *y, pa_bluetooth_profile_t prof
}
}
-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;
@@ -1579,7 +1561,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,
diff --git a/src/modules/bluetooth/bluez5-util.h b/src/modules/bluetooth/bluez5-util.h
index d66e8a3..13d1f0a 100644
--- a/src/modules/bluetooth/bluez5-util.h
+++ b/src/modules/bluetooth/bluez5-util.h
@@ -156,8 +156,7 @@ const char *pa_bluetooth_profile_to_string(pa_bluetooth_profile_t profile);
#define HEADSET_BACKEND_NATIVE 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_set_ofono_running(pa_bluetooth_discovery *y, bool is_running);
#endif
diff --git a/src/modules/bluetooth/module-bluez5-discover.c b/src/modules/bluetooth/module-bluez5-discover.c
index 1ccc1d1..c0e71ad 100644
--- a/src/modules/bluetooth/module-bluez5-discover.c
+++ b/src/modules/bluetooth/module-bluez5-discover.c
@@ -36,14 +36,6 @@ PA_MODULE_AUTHOR("João Paulo Rechi Vita");
PA_MODULE_DESCRIPTION("Detect available BlueZ 5 Bluetooth audio devices and load BlueZ 5 Bluetooth audio drivers");
PA_MODULE_VERSION(PACKAGE_VERSION);
PA_MODULE_LOAD_ONCE(true);
-PA_MODULE_USAGE(
- "headset=ofono|native|auto"
-);
-
-static const char* const valid_modargs[] = {
- "headset",
- NULL
-};
struct userdata {
pa_module *module;
@@ -90,54 +82,26 @@ static pa_hook_result_t device_connection_changed_cb(pa_bluetooth_discovery *y,
return PA_HOOK_OK;
}
-#ifdef HAVE_BLUEZ_5_NATIVE_HEADSET
-const char *default_headset_backend = "native";
-#else
-const char *default_headset_backend = "ofono";
-#endif
-
int pa__init(pa_module *m) {
struct userdata *u;
- pa_modargs *ma;
- const char *headset_str;
- int headset_backend;
pa_assert(m);
- if (!(ma = pa_modargs_new(m->argument, valid_modargs))) {
- pa_log("failed to parse module arguments.");
- goto fail;
- }
-
- pa_assert_se(headset_str = pa_modargs_get_value(ma, "headset", default_headset_backend));
- if (pa_streq(headset_str, "ofono"))
- headset_backend = HEADSET_BACKEND_OFONO;
- else if (pa_streq(headset_str, "native"))
- headset_backend = HEADSET_BACKEND_NATIVE;
- else if (pa_streq(headset_str, "auto"))
- headset_backend = HEADSET_BACKEND_AUTO;
- else {
- pa_log("headset parameter must be either ofono, native or auto (found %s)", headset_str);
- goto fail;
- }
-
m->userdata = u = pa_xnew0(struct userdata, 1);
u->module = m;
u->core = m->core;
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 =
pa_hook_connect(pa_bluetooth_discovery_hook(u->discovery, PA_BLUETOOTH_HOOK_DEVICE_CONNECTION_CHANGED),
PA_HOOK_NORMAL, (pa_hook_cb_t) device_connection_changed_cb, u);
- pa_modargs_free(ma);
return 0;
fail:
- pa_modargs_free(ma);
pa__done(m);
return -1;
}
--
2.1.4
More information about the pulseaudio-discuss
mailing list