[pulseaudio-discuss] [RFC 07/24] bluetooth: Unregister Handsfree Audio Agent with oFono
jprvita at gmail.com
jprvita at gmail.com
Tue Mar 26 22:16:46 PDT 2013
From: João Paulo Rechi Vita <jprvita at openbossa.org>
---
src/modules/bluetooth/bluetooth-util.c | 34 ++++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/src/modules/bluetooth/bluetooth-util.c b/src/modules/bluetooth/bluetooth-util.c
index 38bf58c..21501f8 100644
--- a/src/modules/bluetooth/bluetooth-util.c
+++ b/src/modules/bluetooth/bluetooth-util.c
@@ -1176,6 +1176,34 @@ static void ofono_init(pa_bluetooth_discovery *y) {
send_and_add_to_pending(y, m, hfagent_register_reply, NULL);
}
+static void ofono_done(pa_bluetooth_discovery *y) {
+ pa_assert(y);
+
+ if (y->ofono_bus_id)
+ pa_xfree(y->ofono_bus_id);
+ y->ofono_bus_id = NULL;
+
+ if (y->hf_cards)
+ pa_hashmap_free(y->hf_cards, NULL); /* TODO: free hash entries */
+ y->hf_cards = NULL;
+}
+
+static void ofono_unregister(pa_bluetooth_discovery *y) {
+ DBusMessage *m;
+ const char *path = HFP_AUDIO_AGENT_PATH;
+
+ pa_assert(y);
+ pa_assert(y->ofono_bus_id);
+
+ pa_assert_se(m = dbus_message_new_method_call(y->ofono_bus_id, "/", "org.ofono.HandsfreeAudioManager", "Unregister"));
+
+ 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(y->connection), m, NULL));
+
+ ofono_done(y);
+}
+
static int transport_parse_property(pa_bluetooth_transport *t, DBusMessageIter *i) {
const char *key;
DBusMessageIter variant_i;
@@ -1398,6 +1426,7 @@ static DBusHandlerResult filter_cb(DBusConnection *bus, DBusMessage *m, void *us
if (pa_streq(name, "org.ofono")) {
if (old_owner && *old_owner) {
pa_log_debug("oFono disappeared");
+ ofono_done(y);
}
if (new_owner && *new_owner) {
@@ -2318,11 +2347,16 @@ void pa_bluetooth_discovery_unref(pa_bluetooth_discovery *y) {
}
if (y->connection) {
+
+ if (y->ofono_bus_id)
+ ofono_unregister(y);
+
dbus_connection_unregister_object_path(pa_dbus_connection_get(y->connection), HFP_AG_ENDPOINT);
dbus_connection_unregister_object_path(pa_dbus_connection_get(y->connection), HFP_HS_ENDPOINT);
dbus_connection_unregister_object_path(pa_dbus_connection_get(y->connection), A2DP_SOURCE_ENDPOINT);
dbus_connection_unregister_object_path(pa_dbus_connection_get(y->connection), A2DP_SINK_ENDPOINT);
dbus_connection_unregister_object_path(pa_dbus_connection_get(y->connection), HFP_AUDIO_AGENT_PATH);
+
pa_dbus_remove_matches(
pa_dbus_connection_get(y->connection),
"type='signal',sender='org.freedesktop.DBus',interface='org.freedesktop.DBus',member='NameOwnerChanged'"
--
1.7.11.7
More information about the pulseaudio-discuss
mailing list