[pulseaudio-discuss] [RFCv3 10/20] bluetooth: Track org.ofono.HandsfreeAudioManager.CardRemoved
jprvita at gmail.com
jprvita at gmail.com
Sun Apr 21 20:07:40 PDT 2013
From: João Paulo Rechi Vita <jprvita at openbossa.org>
When a HF card is removed its transport has to be disconnected and
removed from the discovery and device internal structures.
---
src/modules/bluetooth/bluetooth-util.c | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/src/modules/bluetooth/bluetooth-util.c b/src/modules/bluetooth/bluetooth-util.c
index f0ebbcb..8433a3a 100644
--- a/src/modules/bluetooth/bluetooth-util.c
+++ b/src/modules/bluetooth/bluetooth-util.c
@@ -1738,6 +1738,34 @@ static DBusHandlerResult filter_cb(DBusConnection *bus, DBusMessage *m, void *us
hfagent_card_found(y, path, &props_i);
+ } else if (dbus_message_is_signal(m, "org.ofono.HandsfreeAudioManager", "CardRemoved")) {
+ const char *path;
+ pa_bluetooth_transport *t;
+ struct handsfree_card *hf_card;
+ bool old_any_connected;
+
+ if (!dbus_message_get_args(m, &err, DBUS_TYPE_OBJECT_PATH, &path, DBUS_TYPE_INVALID)) {
+ pa_log_error("Failed to parse org.ofono.HandsfreeAudioManager.CardRemoved: %s", err.message);
+ goto fail;
+ }
+
+
+ if ((t = pa_hashmap_remove(y->transports, path)) != NULL) {
+
+ old_any_connected = pa_bluetooth_device_any_audio_connected(t->device);
+
+ t->device->transports[t->profile] = NULL;
+ t->state = PA_BLUETOOTH_TRANSPORT_STATE_DISCONNECTED;
+ pa_hook_fire(&y->hooks[PA_BLUETOOTH_HOOK_TRANSPORT_STATE_CHANGED], t);
+
+ if (old_any_connected != pa_bluetooth_device_any_audio_connected(t->device))
+ run_callback(t->device, false);
+
+ transport_free(t);
+ }
+
+ if ((hf_card = pa_hashmap_remove(y->hf_cards, path)) != NULL)
+ hf_card_free(hf_card);
}
fail:
@@ -2511,6 +2539,7 @@ pa_bluetooth_discovery* pa_bluetooth_discovery_get(pa_core *c) {
"type='signal',sender='org.freedesktop.DBus',interface='org.freedesktop.DBus',member='NameOwnerChanged',"
"arg0='org.ofono'",
"type='signal',sender='org.ofono',interface='org.ofono.HandsfreeAudioManager',member='CardAdded'",
+ "type='signal',sender='org.ofono',interface='org.ofono.HandsfreeAudioManager',member='CardRemoved'",
NULL) < 0) {
pa_log("Failed to add D-Bus matches: %s", err.message);
goto fail;
@@ -2597,6 +2626,7 @@ void pa_bluetooth_discovery_unref(pa_bluetooth_discovery *y) {
"type='signal',sender='org.freedesktop.DBus',interface='org.freedesktop.DBus',member='NameOwnerChanged',"
"arg0='org.ofono'",
"type='signal',sender='org.ofono',interface='org.ofono.HandsfreeAudioManager',member='CardAdded'",
+ "type='signal',sender='org.ofono',interface='org.ofono.HandsfreeAudioManager',member='CardRemoved'",
NULL);
if (y->filter_added)
--
1.7.11.7
More information about the pulseaudio-discuss
mailing list