Skip to content

Commit 4f2ef51

Browse files
Thalleyjhedberg
authored andcommitted
Bluetooth: BAP: UC: Move iso_bind_ep to config instead of QoS
We can actually already when we bind the endpoint to the stream perform the call to bt_bap_iso_bind_ep, if the stream has been added to a group. If the stream has not yet been added to a group, then when the stream is added to a group, then bt_bap_iso_bind_ep will be done there (existing behavior). Signed-off-by: Emil Gydesen <[email protected]>
1 parent 50eb0fb commit 4f2ef51

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

subsys/bluetooth/audio/bap_stream.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -642,11 +642,30 @@ int bt_bap_stream_config(struct bt_conn *conn, struct bt_bap_stream *stream, str
642642
return -EBADMSG;
643643
}
644644

645+
if (ep->stream != NULL) {
646+
LOG_DBG("Endpoint %p already configured for stream %p", ep, stream);
647+
648+
return -EINVAL;
649+
}
650+
__ASSERT(ep->iso == NULL, "endpoint %p already bound to iso %p", ep, ep->iso);
651+
645652
bt_bap_stream_attach(conn, stream, ep, codec_cfg);
646653

654+
/* If a stream has been added to a group at this point, then it has a reference to a CIS.
655+
* and we can bind the ep to the CIS
656+
*/
657+
if (stream->iso != NULL) {
658+
struct bt_bap_iso *bap_iso = CONTAINER_OF(stream->iso, struct bt_bap_iso, chan);
659+
660+
/* Not yet bound with the bap_iso */
661+
bt_bap_iso_bind_ep(bap_iso, ep);
662+
}
663+
647664
err = bt_bap_unicast_client_config(stream, codec_cfg);
648665
if (err != 0) {
649666
LOG_DBG("Failed to configure stream: %d", err);
667+
668+
bt_bap_stream_reset(stream);
650669
return err;
651670
}
652671

subsys/bluetooth/audio/bap_unicast_client.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3453,14 +3453,6 @@ int bt_bap_unicast_client_qos(struct bt_conn *conn, struct bt_bap_unicast_group
34533453

34543454
op->num_ases++;
34553455

3456-
if (stream->ep->iso == NULL) {
3457-
struct bt_bap_iso *bap_iso =
3458-
CONTAINER_OF(stream->iso, struct bt_bap_iso, chan);
3459-
3460-
/* Not yet bound with the bap_iso */
3461-
bt_bap_iso_bind_ep(bap_iso, stream->ep);
3462-
}
3463-
34643456
err = bt_bap_unicast_client_ep_qos(stream->ep, buf, stream->qos);
34653457
if (err != 0) {
34663458
audio_stream_qos_cleanup(conn, group);

0 commit comments

Comments
 (0)