All of lore.kernel.org
 help / color / mirror / Atom feed
From: Claudia Draghicescu <claudia.rosu@nxp.com>
To: linux-bluetooth@vger.kernel.org
Cc: iulia.tanasescu@nxp.com, mihai-octavian.urzica@nxp.com,
	silviu.barbulescu@nxp.com, vlad.pruteanu@nxp.com,
	andrei.istodorescu@nxp.com,
	Claudia Draghicescu <claudia.rosu@nxp.com>
Subject: [PATCH BlueZ 2/2] bap: Fix source+sink endpoint registration
Date: Fri, 13 Oct 2023 13:05:37 +0300	[thread overview]
Message-ID: <20231013100537.3867-3-claudia.rosu@nxp.com> (raw)
In-Reply-To: <20231013100537.3867-1-claudia.rosu@nxp.com>

Create new endpoint name for the simulated broadcast sink that is
created when registering a broadcast source endpoint.
This removes the ambiguity when having registered a local
broadcast sink and fixes the situation when multiple remote
endpoints are created when discovering a broadcast source.

---
 profiles/audio/bap.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/profiles/audio/bap.c b/profiles/audio/bap.c
index fa5cf1f54..cdb84d4bd 100644
--- a/profiles/audio/bap.c
+++ b/profiles/audio/bap.c
@@ -1053,6 +1053,7 @@ static struct bap_ep *ep_register_bcast(struct bap_data *data,
 	switch (bt_bap_pac_get_type(rpac)) {
 	case BT_BAP_BCAST_SOURCE:
 	case BT_BAP_BCAST_SINK:
+	case BT_BAP_SIMULATED_BCAST_SINK:
 		queue = data->bcast;
 		i = queue_length(data->bcast);
 		suffix = "bcast";
@@ -1075,6 +1076,7 @@ static struct bap_ep *ep_register_bcast(struct bap_data *data,
 
 	switch (bt_bap_pac_get_type(rpac)) {
 	case BT_BAP_BCAST_SINK:
+	case BT_BAP_SIMULATED_BCAST_SINK:
 		err = asprintf(&ep->path, "%s/pac_%s%d",
 				adapter_get_path(adapter), suffix, i);
 		ep->base = new0(struct iovec, 1);
@@ -1266,6 +1268,9 @@ static bool pac_found_bcast(struct bt_bap_pac *lpac, struct bt_bap_pac *rpac,
 
 	DBG("lpac %p rpac %p", lpac, rpac);
 
+	if (bt_bap_pac_get_type(lpac) == BT_BAP_SIMULATED_BCAST_SINK)
+		return true;
+
 	ep = ep_register_bcast(user_data, lpac, rpac);
 	if (!ep) {
 		error("Unable to register endpoint for pac %p", rpac);
@@ -1792,7 +1797,7 @@ static void bap_listen_io_broadcast(struct bap_data *data, struct bap_ep *ep,
 		error("%s", err->message);
 		g_error_free(err);
 	}
-
+	ep->io = io;
 	ep->data->listen_io = io;
 
 }
@@ -1958,12 +1963,8 @@ static void pac_added_broadcast(struct bt_bap_pac *pac, void *user_data)
 {
 	struct bap_data *data = user_data;
 
-	if (bt_bap_pac_get_type(pac) == BT_BAP_BCAST_SOURCE)
-		bt_bap_foreach_pac(data->bap, BT_BAP_BCAST_SOURCE,
-						pac_found_bcast, data);
-	else if (bt_bap_pac_get_type(pac) == BT_BAP_BCAST_SINK)
-		bt_bap_foreach_pac(data->bap, BT_BAP_BCAST_SINK,
-						pac_found_bcast, data);
+	bt_bap_foreach_pac(data->bap, bt_bap_pac_get_type(pac),
+				pac_found_bcast, data);
 }
 
 static bool ep_match_pac(const void *data, const void *match_data)
-- 
2.39.2


      parent reply	other threads:[~2023-10-13 10:06 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-13 10:05 [PATCH BlueZ 0/2] bap: Fix source+sink endpoint registration Claudia Draghicescu
2023-10-13 10:05 ` [PATCH BlueZ 1/2] " Claudia Draghicescu
2023-10-13 11:26   ` bluez.test.bot
2023-10-13 17:29   ` [PATCH BlueZ 1/2] " Luiz Augusto von Dentz
2023-10-16 13:27     ` Claudia Draghicescu
2023-10-13 10:05 ` Claudia Draghicescu [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231013100537.3867-3-claudia.rosu@nxp.com \
    --to=claudia.rosu@nxp.com \
    --cc=andrei.istodorescu@nxp.com \
    --cc=iulia.tanasescu@nxp.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=mihai-octavian.urzica@nxp.com \
    --cc=silviu.barbulescu@nxp.com \
    --cc=vlad.pruteanu@nxp.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.