Diff between 0d048414480f7416f38f930c14187c6aea5f4919 and 13dd8c94b5d41951833900810e3509193fdda537

Changed Files

File Additions Deletions Status
profiles/audio/media.c +31 -26 modified

Full Patch

diff --git a/profiles/audio/media.c b/profiles/audio/media.c
index 37eb809..84f8aeb 100644
--- a/profiles/audio/media.c
+++ b/profiles/audio/media.c
@@ -153,6 +153,32 @@ static void media_endpoint_destroy(struct media_endpoint *endpoint)
 	g_free(endpoint);
 }
 
+static struct media_endpoint *media_adapter_find_endpoint(
+						struct media_adapter *adapter,
+						const char *sender,
+						const char *path,
+						const char *uuid)
+{
+	GSList *l;
+
+	for (l = adapter->endpoints; l; l = l->next) {
+		struct media_endpoint *endpoint = l->data;
+
+		if (sender && g_strcmp0(endpoint->sender, sender) != 0)
+			continue;
+
+		if (path && g_strcmp0(endpoint->path, path) != 0)
+			continue;
+
+		if (uuid && g_strcmp0(endpoint->uuid, uuid) != 0)
+			continue;
+
+		return endpoint;
+	}
+
+	return NULL;
+}
+
 static void media_endpoint_remove(struct media_endpoint *endpoint)
 {
 	struct media_adapter *adapter = endpoint->adapter;
@@ -167,6 +193,11 @@ static void media_endpoint_remove(struct media_endpoint *endpoint)
 
 	adapter->endpoints = g_slist_remove(adapter->endpoints, endpoint);
 
+	if (media_adapter_find_endpoint(adapter, NULL, NULL,
+						endpoint->uuid) == NULL)
+		btd_profile_remove_custom_prop(endpoint->uuid,
+							"MediaEndpoints");
+
 	media_endpoint_destroy(endpoint);
 }
 
@@ -576,32 +607,6 @@ static gboolean endpoint_init_a2dp_sink(struct media_endpoint *endpoint,
 	return TRUE;
 }
 
-static struct media_endpoint *media_adapter_find_endpoint(
-						struct media_adapter *adapter,
-						const char *sender,
-						const char *path,
-						const char *uuid)
-{
-	GSList *l;
-
-	for (l = adapter->endpoints; l; l = l->next) {
-		struct media_endpoint *endpoint = l->data;
-
-		if (sender && g_strcmp0(endpoint->sender, sender) != 0)
-			continue;
-
-		if (path && g_strcmp0(endpoint->path, path) != 0)
-			continue;
-
-		if (uuid && g_strcmp0(endpoint->uuid, uuid) != 0)
-			continue;
-
-		return endpoint;
-	}
-
-	return NULL;
-}
-
 static bool endpoint_properties_exists(const char *uuid,
 						struct btd_device *dev,
 						void *user_data)