diff options
author | David Henningsson <david.henningsson@canonical.com> | 2014-11-03 12:13:20 +0100 |
---|---|---|
committer | David Henningsson <david.henningsson@canonical.com> | 2014-11-14 11:44:33 +0100 |
commit | aea3518569fadc65e4eb9003c8190938ad7b26d0 (patch) | |
tree | 95c75a907888e09396d508d21920f288057d3cf9 /src/modules/bluetooth/backend-ofono.c | |
parent | 1ffede3c855d47a371b2d846f2a496797c46e3af (diff) |
bluez 5: Load the native headset backend if the oFono one is unavailable
This implements some autodetect if both headset backends are compiled in:
First we try to contact the oFono service, if that's not working,
then we start the native backend instead.
Likewise if the oFono service is going offline/online, we load/unload
the native backend accordingly.
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
Diffstat (limited to 'src/modules/bluetooth/backend-ofono.c')
-rw-r--r-- | src/modules/bluetooth/backend-ofono.c | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/src/modules/bluetooth/backend-ofono.c b/src/modules/bluetooth/backend-ofono.c index 797d35c5e..1f0c80ff8 100644 --- a/src/modules/bluetooth/backend-ofono.c +++ b/src/modules/bluetooth/backend-ofono.c @@ -336,6 +336,16 @@ static void hf_audio_agent_get_cards(pa_bluetooth_backend *hf) { hf_dbus_send_and_add_to_pending(hf, m, hf_audio_agent_get_cards_reply, NULL); } +static void ofono_bus_id_destroy(pa_bluetooth_backend *backend) { + pa_hashmap_remove_all(backend->cards); + + 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); + } +} + static void hf_audio_agent_register_reply(DBusPendingCall *pending, void *userdata) { DBusMessage *r; pa_dbus_pending *p; @@ -360,6 +370,8 @@ 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) { @@ -393,8 +405,7 @@ static void hf_audio_agent_unregister(pa_bluetooth_backend *backend) { pa_assert_se(dbus_message_append_args(m, DBUS_TYPE_OBJECT_PATH, &path, DBUS_TYPE_INVALID)); pa_assert_se(dbus_connection_send(pa_dbus_connection_get(backend->connection), m, NULL)); - pa_xfree(backend->ofono_bus_id); - backend->ofono_bus_id = NULL; + ofono_bus_id_destroy(backend); } } @@ -429,11 +440,7 @@ static DBusHandlerResult filter_cb(DBusConnection *bus, DBusMessage *m, void *da if (old_owner && *old_owner) { pa_log_debug("oFono disappeared"); - - pa_hashmap_remove_all(backend->cards); - - pa_xfree(backend->ofono_bus_id); - backend->ofono_bus_id = NULL; + ofono_bus_id_destroy(backend); } if (new_owner && *new_owner) { @@ -490,10 +497,7 @@ static DBusMessage *hf_audio_agent_release(DBusConnection *c, DBusMessage *m, vo pa_log_debug("HF audio agent has been unregistered by oFono (%s)", backend->ofono_bus_id); - pa_hashmap_remove_all(backend->cards); - - pa_xfree(backend->ofono_bus_id); - backend->ofono_bus_id = NULL; + ofono_bus_id_destroy(backend); pa_assert_se(r = dbus_message_new_method_return(m)); |