[pulseaudio-discuss] [PATCH] Add option headset=both to module-bluez5-discover

Georg Chini georg at chini.tk
Wed Feb 4 10:28:30 PST 2015


As promised earlier today here is the patch that adds the option "both" for the support
of the bluetooth headset backends. I made "both" the default because the backends currently
support different things and there is no need to choose between them. Tested and working on
my machine. 

---
 src/modules/bluetooth/bluez5-util.c            |  4 +++-
 src/modules/bluetooth/bluez5-util.h            |  1 +
 src/modules/bluetooth/module-bluez5-discover.c | 10 ++++++++--
 3 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/src/modules/bluetooth/bluez5-util.c b/src/modules/bluetooth/bluez5-util.c
index 03c76bf..d5fbbdb 100644
--- a/src/modules/bluetooth/bluez5-util.c
+++ b/src/modules/bluetooth/bluez5-util.c
@@ -915,7 +915,9 @@ static void get_managed_objects_reply(DBusPendingCall *pending, void *userdata)
 
     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)
+    if (!y->native_backend && y->headset_backend == HEADSET_BACKEND_BOTH)
+       y->native_backend = pa_bluetooth_native_backend_new(y->core, y);
+    else if (!y->ofono_backend && !y->native_backend)
         y->native_backend = pa_bluetooth_native_backend_new(y->core, y);
 
 finish:
diff --git a/src/modules/bluetooth/bluez5-util.h b/src/modules/bluetooth/bluez5-util.h
index d66e8a3..a6345df 100644
--- a/src/modules/bluetooth/bluez5-util.h
+++ b/src/modules/bluetooth/bluez5-util.h
@@ -155,6 +155,7 @@ const char *pa_bluetooth_profile_to_string(pa_bluetooth_profile_t profile);
 #define HEADSET_BACKEND_OFONO 0
 #define HEADSET_BACKEND_NATIVE 1
 #define HEADSET_BACKEND_AUTO 2
+#define HEADSET_BACKEND_BOTH 3
 
 pa_bluetooth_discovery* pa_bluetooth_discovery_get(pa_core *core, int headset_backend);
 pa_bluetooth_discovery* pa_bluetooth_discovery_ref(pa_bluetooth_discovery *y);
diff --git a/src/modules/bluetooth/module-bluez5-discover.c b/src/modules/bluetooth/module-bluez5-discover.c
index 1ccc1d1..c7c7679 100644
--- a/src/modules/bluetooth/module-bluez5-discover.c
+++ b/src/modules/bluetooth/module-bluez5-discover.c
@@ -37,7 +37,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=ofono|native|auto"
+    "headset=ofono|native|auto|both"
 );
 
 static const char* const valid_modargs[] = {
@@ -91,7 +91,11 @@ static pa_hook_result_t device_connection_changed_cb(pa_bluetooth_discovery *y,
 }
 
 #ifdef HAVE_BLUEZ_5_NATIVE_HEADSET
+#ifdef HAVE_BLUEZ_5_OFONO_HEADSET
+const char *default_headset_backend = "both";
+#else
 const char *default_headset_backend = "native";
+#endif
 #else
 const char *default_headset_backend = "ofono";
 #endif
@@ -116,8 +120,10 @@ int pa__init(pa_module *m) {
         headset_backend = HEADSET_BACKEND_NATIVE;
     else if (pa_streq(headset_str, "auto"))
         headset_backend = HEADSET_BACKEND_AUTO;
+    else if (pa_streq(headset_str, "both"))
+        headset_backend = HEADSET_BACKEND_BOTH;
     else {
-        pa_log("headset parameter must be either ofono, native or auto (found %s)", headset_str);
+        pa_log("headset parameter must be either ofono, native, auto or both (found %s)", headset_str);
         goto fail;
     }
 
-- 
2.1.4



More information about the pulseaudio-discuss mailing list