[pulseaudio-discuss] [PATCHv2 59/60] bluetooth: Fail to load driver is discovery module is not loaded

jprvita at gmail.com jprvita at gmail.com
Mon Aug 12 21:54:37 PDT 2013


From: João Paulo Rechi Vita <jprvita at openbossa.org>

For quite some time now the device driver module doesn't work well
without the discovery module, so for the BlueZ 5 support we'll prevent
the device driver module to be loaded if the discovery module is not
loaded.
---
 src/modules/bluetooth/bluez5-util.c            | 3 ---
 src/modules/bluetooth/module-bluez5-device.c   | 7 ++++++-
 src/modules/bluetooth/module-bluez5-discover.c | 5 ++++-
 3 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/src/modules/bluetooth/bluez5-util.c b/src/modules/bluetooth/bluez5-util.c
index 3aad10f..3563d57 100644
--- a/src/modules/bluetooth/bluez5-util.c
+++ b/src/modules/bluetooth/bluez5-util.c
@@ -1420,9 +1420,6 @@ pa_bluetooth_discovery* pa_bluetooth_discovery_get(pa_core *c) {
     DBusConnection *conn;
     unsigned i;
 
-    if ((y = pa_shared_get(c, "bluetooth-discovery")))
-        return pa_bluetooth_discovery_ref(y);
-
     y = pa_xnew0(pa_bluetooth_discovery, 1);
     PA_REFCNT_INIT(y);
     y->core = c;
diff --git a/src/modules/bluetooth/module-bluez5-device.c b/src/modules/bluetooth/module-bluez5-device.c
index dd9f40f..3c66c17 100644
--- a/src/modules/bluetooth/module-bluez5-device.c
+++ b/src/modules/bluetooth/module-bluez5-device.c
@@ -39,6 +39,7 @@
 #include <pulsecore/modargs.h>
 #include <pulsecore/poll.h>
 #include <pulsecore/rtpoll.h>
+#include <pulsecore/shared.h>
 #include <pulsecore/socket-util.h>
 #include <pulsecore/thread.h>
 #include <pulsecore/thread-mq.h>
@@ -1796,8 +1797,12 @@ int pa__init(pa_module* m) {
     u->core = m->core;
     u->modargs = ma;
 
-    if (!(u->discovery = pa_bluetooth_discovery_get(m->core)))
+    if ((u->discovery = pa_shared_get(u->core, "bluetooth-discovery")))
+        pa_bluetooth_discovery_ref(u->discovery);
+    else {
+        pa_log_error("module-bluez5-discover doesn't seem to be loaded, refusing to load module-bluez5-device");
         goto fail;
+    }
 
     if (!(u->device = pa_bluetooth_discovery_get_device_by_path(u->discovery, path))) {
         pa_log_error("%s is unknown", path);
diff --git a/src/modules/bluetooth/module-bluez5-discover.c b/src/modules/bluetooth/module-bluez5-discover.c
index e782b2e..a50b9ef 100644
--- a/src/modules/bluetooth/module-bluez5-discover.c
+++ b/src/modules/bluetooth/module-bluez5-discover.c
@@ -27,6 +27,7 @@
 #include <pulsecore/core-util.h>
 #include <pulsecore/macro.h>
 #include <pulsecore/module.h>
+#include <pulsecore/shared.h>
 
 #include "bluez5-util.h"
 
@@ -90,7 +91,9 @@ int pa__init(pa_module* m) {
     u->core = m->core;
     u->device_modules = pa_hashmap_new(pa_idxset_string_hash_func, pa_idxset_string_compare_func);
 
-    if (!(u->discovery = pa_bluetooth_discovery_get(u->core)))
+    if ((u->discovery = pa_shared_get(u->core, "bluetooth-discovery")))
+        pa_bluetooth_discovery_ref(u->discovery);
+    else if (!(u->discovery = pa_bluetooth_discovery_get(u->core)))
         goto fail;
 
     u->device_connection_changed_slot =
-- 
1.7.11.7



More information about the pulseaudio-discuss mailing list