mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-04 13:29:59 -05:00
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>
This commit is contained in:
parent
1ffede3c85
commit
aea3518569
3 changed files with 28 additions and 11 deletions
|
|
@ -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);
|
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) {
|
static void hf_audio_agent_register_reply(DBusPendingCall *pending, void *userdata) {
|
||||||
DBusMessage *r;
|
DBusMessage *r;
|
||||||
pa_dbus_pending *p;
|
pa_dbus_pending *p;
|
||||||
|
|
@ -360,6 +370,8 @@ finish:
|
||||||
|
|
||||||
PA_LLIST_REMOVE(pa_dbus_pending, backend->pending, p);
|
PA_LLIST_REMOVE(pa_dbus_pending, backend->pending, p);
|
||||||
pa_dbus_pending_free(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) {
|
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_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_assert_se(dbus_connection_send(pa_dbus_connection_get(backend->connection), m, NULL));
|
||||||
|
|
||||||
pa_xfree(backend->ofono_bus_id);
|
ofono_bus_id_destroy(backend);
|
||||||
backend->ofono_bus_id = NULL;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -429,11 +440,7 @@ static DBusHandlerResult filter_cb(DBusConnection *bus, DBusMessage *m, void *da
|
||||||
|
|
||||||
if (old_owner && *old_owner) {
|
if (old_owner && *old_owner) {
|
||||||
pa_log_debug("oFono disappeared");
|
pa_log_debug("oFono disappeared");
|
||||||
|
ofono_bus_id_destroy(backend);
|
||||||
pa_hashmap_remove_all(backend->cards);
|
|
||||||
|
|
||||||
pa_xfree(backend->ofono_bus_id);
|
|
||||||
backend->ofono_bus_id = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (new_owner && *new_owner) {
|
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_log_debug("HF audio agent has been unregistered by oFono (%s)", backend->ofono_bus_id);
|
||||||
|
|
||||||
pa_hashmap_remove_all(backend->cards);
|
ofono_bus_id_destroy(backend);
|
||||||
|
|
||||||
pa_xfree(backend->ofono_bus_id);
|
|
||||||
backend->ofono_bus_id = NULL;
|
|
||||||
|
|
||||||
pa_assert_se(r = dbus_message_new_method_return(m));
|
pa_assert_se(r = dbus_message_new_method_return(m));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -861,6 +861,18 @@ static void parse_interfaces_and_properties(pa_bluetooth_discovery *y, DBusMessa
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void pa_bluetooth_discovery_set_ofono_running(pa_bluetooth_discovery *y, bool is_running) {
|
||||||
|
pa_assert(y);
|
||||||
|
|
||||||
|
pa_log_debug("oFono is running: %s", pa_yes_no(is_running));
|
||||||
|
if (is_running && y->native_backend) {
|
||||||
|
pa_bluetooth_native_backend_free(y->native_backend);
|
||||||
|
y->native_backend = NULL;
|
||||||
|
}
|
||||||
|
else if (!is_running && !y->native_backend)
|
||||||
|
y->native_backend = pa_bluetooth_native_backend_new(y->core, y);
|
||||||
|
}
|
||||||
|
|
||||||
static void get_managed_objects_reply(DBusPendingCall *pending, void *userdata) {
|
static void get_managed_objects_reply(DBusPendingCall *pending, void *userdata) {
|
||||||
pa_dbus_pending *p;
|
pa_dbus_pending *p;
|
||||||
pa_bluetooth_discovery *y;
|
pa_bluetooth_discovery *y;
|
||||||
|
|
|
||||||
|
|
@ -157,4 +157,5 @@ const char *pa_bluetooth_profile_to_string(pa_bluetooth_profile_t profile);
|
||||||
pa_bluetooth_discovery* pa_bluetooth_discovery_get(pa_core *core);
|
pa_bluetooth_discovery* pa_bluetooth_discovery_get(pa_core *core);
|
||||||
pa_bluetooth_discovery* pa_bluetooth_discovery_ref(pa_bluetooth_discovery *y);
|
pa_bluetooth_discovery* pa_bluetooth_discovery_ref(pa_bluetooth_discovery *y);
|
||||||
void pa_bluetooth_discovery_unref(pa_bluetooth_discovery *y);
|
void pa_bluetooth_discovery_unref(pa_bluetooth_discovery *y);
|
||||||
|
void pa_bluetooth_discovery_set_ofono_running(pa_bluetooth_discovery *y, bool is_running);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue