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>
This commit is contained in:
David Henningsson 2014-11-03 11:01:00 +01:00
parent 807c98a37d
commit 1ffede3c85
6 changed files with 67 additions and 27 deletions

View file

@ -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);

View file

@ -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);

View file

@ -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) {

View file

@ -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);