The function is used to verify if all the streams from a BIG are in the same state, and if so it returns a new queue with all these streams. This queue will be used to iterate through all configured streams in order of their creation, and create the IOs. --- src/shared/bap.c | 37 +++++++++++++++++++++++++++++++++++++ src/shared/bap.h | 2 ++ 2 files changed, 39 insertions(+) diff --git a/src/shared/bap.c b/src/shared/bap.c index f0ffdebfe..2c5979b96 100644 --- a/src/shared/bap.c +++ b/src/shared/bap.c @@ -6126,3 +6126,40 @@ struct iovec *bt_bap_stream_get_base(struct bt_bap_stream *stream) return base_iov; } + +/* + * Check the state of all streams with the same BIG ID. + * If all the streams are in the checked state, return + * a queue with this streams. + * Else, return NULL. + */ +struct queue *bt_bap_get_streams_by_state(struct bt_bap_stream *stream, + uint8_t test_state) +{ + const struct queue_entry *entry; + struct bt_bap_stream *e_str; + struct queue *return_queue = queue_new(); + + for (entry = queue_get_entries(stream->bap->streams); + entry; entry = entry->next) { + e_str = entry->data; + + if ((e_str->lpac->type != BT_BAP_BCAST_SOURCE) || + (e_str->qos.bcast.big != stream->qos.bcast.big)) + continue; + + if (e_str == stream) { + queue_push_tail(return_queue, e_str); + continue; + } + + if (e_str->ep->state != test_state) { + queue_destroy(return_queue, NULL); + return NULL; + } + + queue_push_tail(return_queue, e_str); + } + + return return_queue; +} diff --git a/src/shared/bap.h b/src/shared/bap.h index 2c3550921..ad6bf2d97 100644 --- a/src/shared/bap.h +++ b/src/shared/bap.h @@ -323,3 +323,5 @@ void bt_bap_update_bcast_source(struct bt_bap_pac *pac, bool bt_bap_pac_bcast_is_local(struct bt_bap *bap, struct bt_bap_pac *pac); struct iovec *bt_bap_stream_get_base(struct bt_bap_stream *stream); +struct queue *bt_bap_get_streams_by_state(struct bt_bap_stream *stream, + uint8_t test_state); -- 2.39.2