This patch tracks when the Handsfree Audio Agent leaves the system BUS,
and free agent allocated resources.
---
plugins/hfp_audio.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/plugins/hfp_audio.c b/plugins/hfp_audio.c
index f46d739..a553afa 100644
--- a/plugins/hfp_audio.c
+++ b/plugins/hfp_audio.c
@@ -42,6 +42,7 @@ struct agent {
char *path;
unsigned char *codecs;
int codecs_len;
+ guint watch;
};
/* Supported agents codecs */
@@ -56,6 +57,9 @@ static void agent_free(gpointer data)
{
struct agent *agent = data;
+ if (agent->watch > 0)
+ g_dbus_remove_watch(ofono_dbus_get_connection(), agent->watch);
+
g_free(agent->owner);
g_free(agent->path);
g_free(agent->codecs);
@@ -86,6 +90,16 @@ static void agent_release(gpointer data, gpointer user_data)
g_dbus_send_message(ofono_dbus_get_connection(), msg);
}
+static void agent_disconnect(DBusConnection *conn, void *user_data)
+{
+ struct agent *agent = user_data;
+
+ DBG("Agent %s disconnected", agent->owner);
+
+ agents = g_slist_remove(agents, agent);
+ agent_free(agent);
+}
+
static DBusMessage *am_get_cards(DBusConnection *conn,
DBusMessage *msg, void *user_data)
{
@@ -133,6 +147,8 @@ static DBusMessage *am_agent_register(DBusConnection *conn,
agent->path = g_strdup(path);
agent->codecs = g_memdup(codecs, length);
agent->codecs_len = length;
+ agent->watch = g_dbus_add_disconnect_watch(conn, sender,
+ agent_disconnect, agent, NULL);
agents = g_slist_prepend(agents, agent);
--
1.7.11.7
_______________________________________________
ofono mailing list
[email protected]
http://lists.ofono.org/listinfo/ofono