2024-01-21 20:27:34

by Pauli Virtanen

[permalink] [raw]
Subject: [PATCH BlueZ] bap: register all endpoints before starting config select

Register all BAP endpoints first, so that they all become visible in
DBus before we start calling SelectProperties() on them.

This allows sound servers to know ahead of time what capabilities the
device has, and plan the configuration.

For example, a sound server might select different configuration for
sink+source configurations as opposed to sink or source only, due to
bandwidth etc. concerns.
---
profiles/audio/bap.c | 48 ++++++++++++++++++++++++++++++++++++++------
1 file changed, 42 insertions(+), 6 deletions(-)

diff --git a/profiles/audio/bap.c b/profiles/audio/bap.c
index 69e982832..8d44e48fe 100644
--- a/profiles/audio/bap.c
+++ b/profiles/audio/bap.c
@@ -1285,7 +1285,7 @@ done:
queue_foreach(ep->data->bcast, bap_config, NULL);
}

-static bool pac_found(struct bt_bap_pac *lpac, struct bt_bap_pac *rpac,
+static bool pac_register(struct bt_bap_pac *lpac, struct bt_bap_pac *rpac,
void *user_data)
{
struct btd_service *service = user_data;
@@ -1294,8 +1294,35 @@ static bool pac_found(struct bt_bap_pac *lpac, struct bt_bap_pac *rpac,
DBG("lpac %p rpac %p", lpac, rpac);

ep = ep_register(service, lpac, rpac);
- if (!ep) {
+ if (!ep)
error("Unable to register endpoint for pac %p", rpac);
+
+ return true;
+}
+
+static bool pac_select(struct bt_bap_pac *lpac, struct bt_bap_pac *rpac,
+ void *user_data)
+{
+ struct btd_service *service = user_data;
+ struct bap_data *data = btd_service_get_user_data(service);
+ struct match_ep match = { lpac, rpac };
+ struct queue *queue;
+ struct bap_ep *ep;
+
+ switch (bt_bap_pac_get_type(rpac)) {
+ case BT_BAP_SINK:
+ queue = data->snks;
+ break;
+ case BT_BAP_SOURCE:
+ queue = data->srcs;
+ break;
+ default:
+ return true;
+ }
+
+ ep = queue_find(queue, match_ep, &match);
+ if (!ep) {
+ error("Unable to find endpoint for pac %p", rpac);
return true;
}

@@ -1328,8 +1355,14 @@ static void bap_ready(struct bt_bap *bap, void *user_data)

DBG("bap %p", bap);

- bt_bap_foreach_pac(bap, BT_BAP_SOURCE, pac_found, service);
- bt_bap_foreach_pac(bap, BT_BAP_SINK, pac_found, service);
+ /* Register all ep before selecting, so that sound server
+ * knows all.
+ */
+ bt_bap_foreach_pac(bap, BT_BAP_SOURCE, pac_register, service);
+ bt_bap_foreach_pac(bap, BT_BAP_SINK, pac_register, service);
+
+ bt_bap_foreach_pac(bap, BT_BAP_SOURCE, pac_select, service);
+ bt_bap_foreach_pac(bap, BT_BAP_SINK, pac_select, service);
}

static bool match_setup_stream(const void *data, const void *user_data)
@@ -2044,8 +2077,11 @@ static void pac_added(struct bt_bap_pac *pac, void *user_data)

data = btd_service_get_user_data(service);

- bt_bap_foreach_pac(data->bap, BT_BAP_SOURCE, pac_found, service);
- bt_bap_foreach_pac(data->bap, BT_BAP_SINK, pac_found, service);
+ bt_bap_foreach_pac(data->bap, BT_BAP_SOURCE, pac_register, service);
+ bt_bap_foreach_pac(data->bap, BT_BAP_SINK, pac_register, service);
+
+ bt_bap_foreach_pac(data->bap, BT_BAP_SOURCE, pac_select, service);
+ bt_bap_foreach_pac(data->bap, BT_BAP_SINK, pac_select, service);
}

static void pac_added_broadcast(struct bt_bap_pac *pac, void *user_data)
--
2.43.0



2024-01-21 21:31:18

by bluez.test.bot

[permalink] [raw]
Subject: RE: [BlueZ] bap: register all endpoints before starting config select

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=818402

---Test result---

Test Summary:
CheckPatch PASS 0.44 seconds
GitLint PASS 0.29 seconds
BuildEll PASS 23.77 seconds
BluezMake PASS 731.33 seconds
MakeCheck PASS 12.37 seconds
MakeDistcheck PASS 159.12 seconds
CheckValgrind PASS 220.08 seconds
CheckSmatch PASS 324.50 seconds
bluezmakeextell PASS 105.64 seconds
IncrementalBuild PASS 689.90 seconds
ScanBuild PENDING 951.99 seconds

Details
##############################
Test: ScanBuild - PENDING
Desc: Run Scan Build
Output:



---
Regards,
Linux Bluetooth

2024-01-22 23:53:24

by patchwork-bot+bluetooth

[permalink] [raw]
Subject: Re: [PATCH BlueZ] bap: register all endpoints before starting config select

Hello:

This patch was applied to bluetooth/bluez.git (master)
by Luiz Augusto von Dentz <[email protected]>:

On Sun, 21 Jan 2024 22:27:06 +0200 you wrote:
> Register all BAP endpoints first, so that they all become visible in
> DBus before we start calling SelectProperties() on them.
>
> This allows sound servers to know ahead of time what capabilities the
> device has, and plan the configuration.
>
> For example, a sound server might select different configuration for
> sink+source configurations as opposed to sink or source only, due to
> bandwidth etc. concerns.
>
> [...]

Here is the summary with links:
- [BlueZ] bap: register all endpoints before starting config select
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=a9d1f6f6a625

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html