2024-02-29 15:18:20

by Luiz Augusto von Dentz

[permalink] [raw]
Subject: [PATCH BlueZ v1] shared/bap: Remove bt_bap_stream_bcast_new

From: Luiz Augusto von Dentz <[email protected]>

This is now handled internally by bt_bap_stream_new by detecting if an
ATT session has been attached.
---
profiles/audio/bap.c | 11 ++-----
src/shared/bap.c | 74 +++++++++++++-------------------------------
src/shared/bap.h | 6 ----
3 files changed, 24 insertions(+), 67 deletions(-)

diff --git a/profiles/audio/bap.c b/profiles/audio/bap.c
index 6cac99140217..de687ae224bb 100644
--- a/profiles/audio/bap.c
+++ b/profiles/audio/bap.c
@@ -68,11 +68,6 @@ struct bap_setup {
struct bt_bap_qos qos;
int (*qos_parser)(struct bap_setup *setup, const char *key, int var,
DBusMessageIter *iter);
- struct bt_bap_stream* (*stream_new)(struct bt_bap *bap,
- struct bt_bap_pac *lpac,
- struct bt_bap_pac *rpac,
- struct bt_bap_qos *pqos,
- struct iovec *data);
GIOChannel *io;
unsigned int io_id;
bool recreate;
@@ -893,13 +888,11 @@ static struct bap_setup *setup_new(struct bap_ep *ep)
setup->qos.bcast.bis = BT_ISO_QOS_BIS_UNSET;
setup->qos_parser = setup_parse_bcast_qos;
setup->destroy = setup_bcast_destroy;
- setup->stream_new = bt_bap_stream_bcast_new;
} else {
/* Mark CIG and CIS to be auto assigned */
setup->qos.ucast.cig_id = BT_ISO_QOS_CIG_UNSET;
setup->qos.ucast.cis_id = BT_ISO_QOS_CIS_UNSET;
setup->qos_parser = setup_parse_ucast_qos;
- setup->stream_new = bt_bap_stream_new;
}

if (!ep->setups)
@@ -965,7 +958,7 @@ static DBusMessage *set_configuration(DBusConnection *conn, DBusMessage *msg,
return btd_error_invalid_args(msg);
}

- setup->stream = setup->stream_new(ep->data->bap, ep->lpac, ep->rpac,
+ setup->stream = bt_bap_stream_new(ep->data->bap, ep->lpac, ep->rpac,
&setup->qos, setup->caps);

setup->id = bt_bap_stream_config(setup->stream, &setup->qos,
@@ -1300,7 +1293,7 @@ static void setup_config(void *data, void *user_data)
* and PHY.
*/
if (!setup->stream)
- setup->stream = setup->stream_new(ep->data->bap, ep->lpac,
+ setup->stream = bt_bap_stream_new(ep->data->bap, ep->lpac,
ep->rpac, &setup->qos,
setup->caps);

diff --git a/src/shared/bap.c b/src/shared/bap.c
index 0931c8fa249f..37a44cd3dc37 100644
--- a/src/shared/bap.c
+++ b/src/shared/bap.c
@@ -5163,7 +5163,7 @@ int bt_bap_select(struct bt_bap_pac *lpac, struct bt_bap_pac *rpac,
return 0;
}

-struct bt_bap_stream *bt_bap_stream_bcast_new(struct bt_bap *bap,
+static struct bt_bap_stream *bap_bcast_stream_new(struct bt_bap *bap,
struct bt_bap_pac *lpac,
struct bt_bap_pac *rpac,
struct bt_bap_qos *pqos,
@@ -5245,66 +5245,20 @@ struct bt_bap_stream *bt_bap_stream_bcast_new(struct bt_bap *bap,
return stream;
}

-struct bt_bap_stream *bt_bap_stream_new(struct bt_bap *bap,
+static struct bt_bap_stream *bap_ucast_stream_new(struct bt_bap *bap,
struct bt_bap_pac *lpac,
struct bt_bap_pac *rpac,
struct bt_bap_qos *pqos,
struct iovec *data)
{
- struct bt_bap_stream *stream;
- struct bt_bap_endpoint *ep;
+ struct bt_bap_stream *stream = NULL;
+ struct bt_bap_endpoint *ep = NULL;
struct match_pac match;

- if (!bap)
+ if (!lpac || !rpac || !bap_codec_equal(&lpac->codec, &rpac->codec))
return NULL;

- if (!rpac && (lpac->type != BT_BAP_BCAST_SOURCE)
- && queue_isempty(bap->remote_eps))
- return NULL;
-
- if (lpac && rpac) {
- if ((rpac->type != BT_BAP_BCAST_SOURCE)
- && (!bap_codec_equal(&lpac->codec, &rpac->codec)))
- return NULL;
- } else {
- uint8_t type;
-
- match.lpac = lpac;
- match.rpac = rpac;
- memset(&match.codec, 0, sizeof(match.codec));
-
- if (rpac)
- type = rpac->type;
- else if (lpac) {
- switch (lpac->type) {
- case BT_BAP_SINK:
- type = BT_BAP_SOURCE;
- break;
- case BT_BAP_SOURCE:
- type = BT_BAP_SINK;
- break;
- case BT_BAP_BCAST_SOURCE:
- type = BT_BAP_BCAST_SINK;
- break;
- case BT_BAP_BCAST_SINK:
- type = BT_BAP_BCAST_SOURCE;
- break;
- default:
- return NULL;
- }
- } else
- return NULL;
-
- bt_bap_foreach_pac(bap, type, match_pac, &match);
- if ((!match.lpac) || (!lpac))
- return NULL;
- if (!match.rpac && (lpac->type != BT_BAP_BCAST_SOURCE))
- return NULL;
-
- lpac = match.lpac;
- rpac = match.rpac;
- }
-
+ memset(&match, 0, sizeof(match));
match.lpac = lpac;
match.rpac = rpac;

@@ -5326,6 +5280,22 @@ struct bt_bap_stream *bt_bap_stream_new(struct bt_bap *bap,
return stream;
}

+struct bt_bap_stream *bt_bap_stream_new(struct bt_bap *bap,
+ struct bt_bap_pac *lpac,
+ struct bt_bap_pac *rpac,
+ struct bt_bap_qos *pqos,
+ struct iovec *data)
+{
+ if (!bap)
+ return NULL;
+
+ /* Check if ATT is attached then it must be a unicast stream */
+ if (bt_bap_get_att(bap))
+ return bap_ucast_stream_new(bap, lpac, rpac, pqos, data);
+
+ return bap_bcast_stream_new(bap, lpac, rpac, pqos, data);
+}
+
struct bt_bap *bt_bap_stream_get_session(struct bt_bap_stream *stream)
{
if (!stream)
diff --git a/src/shared/bap.h b/src/shared/bap.h
index fa0d4b524ffd..2c3550921f07 100644
--- a/src/shared/bap.h
+++ b/src/shared/bap.h
@@ -244,12 +244,6 @@ struct bt_bap_stream *bt_bap_stream_new(struct bt_bap *bap,
struct bt_bap_qos *pqos,
struct iovec *data);

-struct bt_bap_stream *bt_bap_stream_bcast_new(struct bt_bap *bap,
- struct bt_bap_pac *lpac,
- struct bt_bap_pac *rpac,
- struct bt_bap_qos *pqos,
- struct iovec *data);
-
struct bt_bap *bt_bap_stream_get_session(struct bt_bap_stream *stream);
uint8_t bt_bap_stream_get_state(struct bt_bap_stream *stream);

--
2.43.0



2024-02-29 16:43:15

by bluez.test.bot

[permalink] [raw]
Subject: RE: [BlueZ,v1] shared/bap: Remove bt_bap_stream_bcast_new

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=831152

---Test result---

Test Summary:
CheckPatch PASS 0.47 seconds
GitLint PASS 0.30 seconds
BuildEll PASS 23.78 seconds
BluezMake PASS 724.51 seconds
MakeCheck PASS 12.30 seconds
MakeDistcheck PASS 162.73 seconds
CheckValgrind PASS 228.64 seconds
CheckSmatch PASS 330.72 seconds
bluezmakeextell PASS 107.48 seconds
IncrementalBuild PASS 677.84 seconds
ScanBuild PASS 942.33 seconds



---
Regards,
Linux Bluetooth