Diff between c18829a8bf7999ce9b4b6233e343d9aafe7fd11b and c954096a11fd51873fb0dd9e099e9cbb1317cf12

Changed Files

File Additions Deletions Status
profiles/audio/media.c +16 -2 modified

Full Patch

diff --git a/profiles/audio/media.c b/profiles/audio/media.c
index 74064d3..c84bbe2 100644
--- a/profiles/audio/media.c
+++ b/profiles/audio/media.c
@@ -71,6 +71,7 @@ struct media_adapter {
 
 struct endpoint_request {
 	struct media_endpoint	*endpoint;
+	struct media_transport	*transport;
 	DBusMessage		*msg;
 	DBusPendingCall		*call;
 	media_endpoint_cb_t	cb;
@@ -298,6 +299,15 @@ static void endpoint_reply(DBusPendingCall *call, void *user_data)
 			return;
 		}
 
+		if (dbus_message_is_method_call(request->msg,
+					MEDIA_ENDPOINT_INTERFACE,
+					"SetConfiguration")) {
+			if (request->transport == NULL)
+				error("Expected to destroy transport");
+			else
+				media_transport_destroy(request->transport);
+		}
+
 		dbus_error_free(&err);
 		goto done;
 	}
@@ -337,6 +347,7 @@ done:
 
 static gboolean media_endpoint_async_call(DBusMessage *msg,
 					struct media_endpoint *endpoint,
+					struct media_transport *transport,
 					media_endpoint_cb_t cb,
 					void *user_data,
 					GDestroyNotify destroy)
@@ -358,6 +369,7 @@ static gboolean media_endpoint_async_call(DBusMessage *msg,
 									NULL);
 
 	request->endpoint = endpoint;
+	request->transport = transport;
 	request->msg = msg;
 	request->cb = cb;
 	request->destroy = destroy;
@@ -393,7 +405,8 @@ static gboolean select_configuration(struct media_endpoint *endpoint,
 					&capabilities, length,
 					DBUS_TYPE_INVALID);
 
-	return media_endpoint_async_call(msg, endpoint, cb, user_data, destroy);
+	return media_endpoint_async_call(msg, endpoint, NULL,
+						cb, user_data, destroy);
 }
 
 static int transport_device_cmp(gconstpointer data, gconstpointer user_data)
@@ -501,7 +514,8 @@ static gboolean set_configuration(struct media_endpoint *endpoint,
 
 	g_dbus_get_properties(conn, path, "org.bluez.MediaTransport1", &iter);
 
-	return media_endpoint_async_call(msg, endpoint, cb, user_data, destroy);
+	return media_endpoint_async_call(msg, endpoint, transport,
+						cb, user_data, destroy);
 }
 
 static void release_endpoint(struct media_endpoint *endpoint)