summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Henningsson <david.henningsson@canonical.com>2014-11-03 11:01:00 +0100
committerDavid Henningsson <david.henningsson@canonical.com>2014-11-14 11:44:33 +0100
commit1ffede3c855d47a371b2d846f2a496797c46e3af (patch)
treee56832f0c82be6d0d2d96beb7c46e6779a2bc902
parent807c98a37dcdb65557847cd79e657bfe29c12698 (diff)
bluez 5: Build both headset backends, if available
Enable both ofono and native backends to be built into the same libbluez5-util. Never build the null backend. Signed-off-by: David Henningsson <david.henningsson@canonical.com>
-rw-r--r--configure.ac33
-rw-r--r--src/Makefile.am12
-rw-r--r--src/modules/bluetooth/backend-native.c4
-rw-r--r--src/modules/bluetooth/backend-ofono.c4
-rw-r--r--src/modules/bluetooth/bluez5-util.c24
-rw-r--r--src/modules/bluetooth/bluez5-util.h21
6 files changed, 69 insertions, 29 deletions
diff --git a/configure.ac b/configure.ac
index 6b67dac34..e91e99014 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1035,18 +1035,22 @@ AM_CONDITIONAL([HAVE_BLUEZ], [test "x$HAVE_BLUEZ" = x1])
## Bluetooth Headset profiles backend ##
-AC_ARG_WITH(bluetooth_headset_backend,
- AS_HELP_STRING([--with-bluetooth-headset-backend=<ofono|native|null>],[Backend for Bluetooth headset profiles (native)]))
-if test -z "$with_bluetooth_headset_backend" ; then
- BLUETOOTH_HEADSET_BACKEND=native
-else
- BLUETOOTH_HEADSET_BACKEND=$with_bluetooth_headset_backend
-fi
-
-AS_IF([test "x$BLUETOOTH_HEADSET_BACKEND" != "xofono" && test "x$BLUETOOTH_HEADSET_BACKEND" != "xnull" && test "x$BLUETOOTH_HEADSET_BACKEND" != "xnative"],
- [AC_MSG_ERROR([*** Invalid Bluetooth Headset backend])])
-
-AC_SUBST(BLUETOOTH_HEADSET_BACKEND)
+AC_ARG_ENABLE([bluez5-ofono-headset],
+ AS_HELP_STRING([--disable-bluez5-ofono-headset],[Disable optional ofono headset backend support (Bluez 5)]))
+AS_IF([test "x$HAVE_BLUEZ_5" = "x1" && test "x$enable_bluez5_ofono_headset" != "xno"], HAVE_BLUEZ_5_OFONO_HEADSET=1)
+AC_SUBST(HAVE_BLUEZ_5_OFONO_HEADSET)
+AM_CONDITIONAL([HAVE_BLUEZ_5_OFONO_HEADSET], [test "x$HAVE_BLUEZ_5_OFONO_HEADSET" = x1])
+AS_IF([test "x$HAVE_BLUEZ_5_OFONO_HEADSET" = "x1"], AC_DEFINE([HAVE_BLUEZ_5_OFONO_HEADSET], 1, [Bluez 5 ofono headset backend enabled]))
+
+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"], HAVE_BLUEZ_5_NATIVE_HEADSET=1)
+AS_IF([test "x$HAVE_BLUEZ_5_NATIVE_HEADSET" = "x1"], [PKG_CHECK_MODULES(BLUEZ, [ bluez >= 4.101 ], [],
+ [AC_MSG_ERROR([*** Bluez library not found (required by native headset backend)])])])
+
+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]))
#### UDEV support (optional) ####
@@ -1509,6 +1513,8 @@ AS_IF([test "x$HAVE_SYSTEMD_LOGIN" = "x1"], ENABLE_SYSTEMD_LOGIN=yes, ENABLE_SYS
AS_IF([test "x$HAVE_SYSTEMD_JOURNAL" = "x1"], ENABLE_SYSTEMD_JOURNAL=yes, ENABLE_SYSTEMD_JOURNAL=no)
AS_IF([test "x$HAVE_BLUEZ_4" = "x1"], ENABLE_BLUEZ_4=yes, ENABLE_BLUEZ_4=no)
AS_IF([test "x$HAVE_BLUEZ_5" = "x1"], ENABLE_BLUEZ_5=yes, ENABLE_BLUEZ_5=no)
+AS_IF([test "x$HAVE_BLUEZ_5_OFONO_HEADSET" = "x1"], ENABLE_BLUEZ_5_OFONO_HEADSET=yes, ENABLE_BLUEZ_5_OFONO_HEADSET=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_HAL_COMPAT" = "x1"], ENABLE_HAL_COMPAT=yes, ENABLE_HAL_COMPAT=no)
AS_IF([test "x$HAVE_TCPWRAP" = "x1"], ENABLE_TCPWRAP=yes, ENABLE_TCPWRAP=no)
AS_IF([test "x$HAVE_LIBSAMPLERATE" = "x1"], ENABLE_LIBSAMPLERATE=yes, ENABLE_LIBSAMPLERATE=no)
@@ -1563,7 +1569,8 @@ echo "
Enable D-Bus: ${ENABLE_DBUS}
Enable BlueZ 4: ${ENABLE_BLUEZ_4}
Enable BlueZ 5: ${ENABLE_BLUEZ_5}
- headset backend: ${BLUETOOTH_HEADSET_BACKEND}
+ Enable ofono headsets: ${ENABLE_BLUEZ_5_OFONO_HEADSET}
+ Enable native headsets: ${ENABLE_BLUEZ_5_NATIVE_HEADSET}
Enable udev: ${ENABLE_UDEV}
Enable HAL->udev compat: ${ENABLE_HAL_COMPAT}
Enable systemd
diff --git a/src/Makefile.am b/src/Makefile.am
index 3cab31f14..4e60a9852 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -2129,8 +2129,16 @@ module_bluez4_device_la_CFLAGS = $(AM_CFLAGS) $(DBUS_CFLAGS) $(SBC_CFLAGS)
libbluez5_util_la_SOURCES = \
modules/bluetooth/bluez5-util.c \
modules/bluetooth/bluez5-util.h \
- modules/bluetooth/a2dp-codecs.h \
- modules/bluetooth/backend-@BLUETOOTH_HEADSET_BACKEND@.c
+ modules/bluetooth/a2dp-codecs.h
+if HAVE_BLUEZ_5_OFONO_HEADSET
+libbluez5_util_la_SOURCES += \
+ modules/bluetooth/backend-ofono.c
+endif
+if HAVE_BLUEZ_5_NATIVE_HEADSET
+libbluez5_util_la_SOURCES += \
+ modules/bluetooth/backend-native.c
+endif
+
libbluez5_util_la_LDFLAGS = -avoid-version
libbluez5_util_la_LIBADD = $(MODULE_LIBADD) $(DBUS_LIBS)
libbluez5_util_la_CFLAGS = $(AM_CFLAGS) $(DBUS_CFLAGS)
diff --git a/src/modules/bluetooth/backend-native.c b/src/modules/bluetooth/backend-native.c
index a9dc64cfe..66dacf9b0 100644
--- a/src/modules/bluetooth/backend-native.c
+++ b/src/modules/bluetooth/backend-native.c
@@ -464,7 +464,7 @@ static void profile_done(pa_bluetooth_backend *b, pa_bluetooth_profile_t profile
}
}
-pa_bluetooth_backend *pa_bluetooth_backend_new(pa_core *c, pa_bluetooth_discovery *y) {
+pa_bluetooth_backend *pa_bluetooth_native_backend_new(pa_core *c, pa_bluetooth_discovery *y) {
pa_bluetooth_backend *backend;
DBusError err;
@@ -488,7 +488,7 @@ pa_bluetooth_backend *pa_bluetooth_backend_new(pa_core *c, pa_bluetooth_discover
return backend;
}
-void pa_bluetooth_backend_free(pa_bluetooth_backend *backend) {
+void pa_bluetooth_native_backend_free(pa_bluetooth_backend *backend) {
pa_assert(backend);
pa_dbus_free_pending_list(&backend->pending);
diff --git a/src/modules/bluetooth/backend-ofono.c b/src/modules/bluetooth/backend-ofono.c
index ba10ed663..797d35c5e 100644
--- a/src/modules/bluetooth/backend-ofono.c
+++ b/src/modules/bluetooth/backend-ofono.c
@@ -582,7 +582,7 @@ static DBusHandlerResult hf_audio_agent_handler(DBusConnection *c, DBusMessage *
return DBUS_HANDLER_RESULT_HANDLED;
}
-pa_bluetooth_backend *pa_bluetooth_backend_new(pa_core *c, pa_bluetooth_discovery *y) {
+pa_bluetooth_backend *pa_bluetooth_ofono_backend_new(pa_core *c, pa_bluetooth_discovery *y) {
pa_bluetooth_backend *backend;
DBusError err;
static const DBusObjectPathVTable vtable_hf_audio_agent = {
@@ -635,7 +635,7 @@ pa_bluetooth_backend *pa_bluetooth_backend_new(pa_core *c, pa_bluetooth_discover
return backend;
}
-void pa_bluetooth_backend_free(pa_bluetooth_backend *backend) {
+void pa_bluetooth_ofono_backend_free(pa_bluetooth_backend *backend) {
pa_assert(backend);
pa_dbus_free_pending_list(&backend->pending);
diff --git a/src/modules/bluetooth/bluez5-util.c b/src/modules/bluetooth/bluez5-util.c
index 9431aed6e..f7bf65485 100644
--- a/src/modules/bluetooth/bluez5-util.c
+++ b/src/modules/bluetooth/bluez5-util.c
@@ -87,7 +87,7 @@ struct pa_bluetooth_discovery {
pa_hashmap *devices;
pa_hashmap *transports;
- pa_bluetooth_backend *backend;
+ pa_bluetooth_backend *ofono_backend, *native_backend;
PA_LLIST_HEAD(pa_dbus_pending, pending);
};
@@ -899,8 +899,10 @@ static void get_managed_objects_reply(DBusPendingCall *pending, void *userdata)
y->objects_listed = true;
- if (!y->backend)
- y->backend = pa_bluetooth_backend_new(y->core, y);
+ if (!y->ofono_backend)
+ y->ofono_backend = pa_bluetooth_ofono_backend_new(y->core, y);
+ if (!y->ofono_backend && !y->native_backend)
+ y->native_backend = pa_bluetooth_native_backend_new(y->core, y);
finish:
dbus_message_unref(r);
@@ -954,9 +956,13 @@ 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->backend) {
- pa_bluetooth_backend_free(y->backend);
- y->backend = NULL;
+ if (y->ofono_backend) {
+ pa_bluetooth_ofono_backend_free(y->ofono_backend);
+ y->ofono_backend = NULL;
+ }
+ if (y->native_backend) {
+ pa_bluetooth_native_backend_free(y->native_backend);
+ y->native_backend = NULL;
}
}
@@ -1648,8 +1654,10 @@ void pa_bluetooth_discovery_unref(pa_bluetooth_discovery *y) {
pa_hashmap_free(y->transports);
}
- if (y->backend)
- pa_bluetooth_backend_free(y->backend);
+ if (y->ofono_backend)
+ pa_bluetooth_ofono_backend_free(y->ofono_backend);
+ if (y->native_backend)
+ pa_bluetooth_native_backend_free(y->native_backend);
if (y->connection) {
diff --git a/src/modules/bluetooth/bluez5-util.h b/src/modules/bluetooth/bluez5-util.h
index 3ef0ac837..d1abd39b5 100644
--- a/src/modules/bluetooth/bluez5-util.h
+++ b/src/modules/bluetooth/bluez5-util.h
@@ -117,8 +117,25 @@ struct pa_bluetooth_adapter {
bool valid;
};
-pa_bluetooth_backend *pa_bluetooth_backend_new(pa_core *c, pa_bluetooth_discovery *y);
-void pa_bluetooth_backend_free(pa_bluetooth_backend *b);
+#ifdef HAVE_BLUEZ_5_OFONO_HEADSET
+pa_bluetooth_backend *pa_bluetooth_ofono_backend_new(pa_core *c, pa_bluetooth_discovery *y);
+void pa_bluetooth_ofono_backend_free(pa_bluetooth_backend *b);
+#else
+static inline pa_bluetooth_backend *pa_bluetooth_ofono_backend_new(pa_core *c, pa_bluetooth_discovery *y) {
+ return NULL;
+}
+static inline void pa_bluetooth_ofono_backend_free(pa_bluetooth_backend *b) {}
+#endif
+
+#ifdef HAVE_BLUEZ_5_NATIVE_HEADSET
+pa_bluetooth_backend *pa_bluetooth_native_backend_new(pa_core *c, pa_bluetooth_discovery *y);
+void pa_bluetooth_native_backend_free(pa_bluetooth_backend *b);
+#else
+static inline pa_bluetooth_backend *pa_bluetooth_native_backend_new(pa_core *c, pa_bluetooth_discovery *y) {
+ return NULL;
+}
+static inline void pa_bluetooth_native_backend_free(pa_bluetooth_backend *b) {}
+#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);