Diff between 814e3535a1bc165e05d91c470b38e835c5006ac9 and b61044d52917eb44468b46bfcafb191d18418698

Changed Files

File Additions Deletions Status
profiles/audio/bap.c +21 -0 modified

Full Patch

diff --git a/profiles/audio/bap.c b/profiles/audio/bap.c
index 5a50a2c..e5ffb72 100644
--- a/profiles/audio/bap.c
+++ b/profiles/audio/bap.c
@@ -510,6 +510,22 @@ static void ep_free(void *data)
 	free(ep);
 }
 
+struct match_ep {
+	struct bt_bap_pac *lpac;
+	struct bt_bap_pac *rpac;
+};
+
+static bool match_ep(const void *data, const void *user_data)
+{
+	const struct bap_ep *ep = data;
+	const struct match_ep *match = user_data;
+
+	if (ep->lpac != match->lpac)
+		return false;
+
+	return ep->rpac == match->rpac;
+}
+
 static struct bap_ep *ep_register(struct btd_service *service,
 					struct bt_bap_pac *lpac,
 					struct bt_bap_pac *rpac)
@@ -520,6 +536,7 @@ static struct bap_ep *ep_register(struct btd_service *service,
 	struct queue *queue;
 	int i, err;
 	const char *suffix;
+	struct match_ep match = { lpac, rpac };
 
 	switch (bt_bap_pac_get_type(rpac)) {
 	case BT_BAP_SINK:
@@ -536,6 +553,10 @@ static struct bap_ep *ep_register(struct btd_service *service,
 		return NULL;
 	}
 
+	ep = queue_find(queue, match_ep, &match);
+	if (ep)
+		return ep;
+
 	ep = new0(struct bap_ep, 1);
 	ep->data = data;
 	ep->lpac = lpac;