Hi,
ma, 2023-10-02 kello 18:33 +0300, Iulia Tanasescu kirjoitti:
> From: Silviu Florian Barbulescu <[email protected]>
>
> Update transport release flow for broadcast source
>
> ---
> profiles/audio/transport.c | 63 ++++++++++++++++++++++----------------
> 1 file changed, 36 insertions(+), 27 deletions(-)
>
> diff --git a/profiles/audio/transport.c b/profiles/audio/transport.c
> index 1e03b7b51..646061358 100644
> --- a/profiles/audio/transport.c
> +++ b/profiles/audio/transport.c
> @@ -606,11 +606,38 @@ static DBusMessage *try_acquire(DBusConnection *conn, DBusMessage *msg,
> return NULL;
> }
>
> +static void bap_stop_complete(struct bt_bap_stream *stream,
> + uint8_t code, uint8_t reason,
> + void *user_data)
> +{
> + struct media_owner *owner = user_data;
> + struct media_request *req = owner->pending;
> + struct media_transport *transport = owner->transport;
> +
> + /* Release always succeeds */
> + if (req) {
> + req->id = 0;
> + media_request_reply(req, 0);
> + media_owner_remove(owner);
> + }
> +
> + transport_set_state(transport, TRANSPORT_STATE_IDLE);
> + media_transport_remove_owner(transport);
> +}
> +
> +static void bap_disable_complete(struct bt_bap_stream *stream,
> + uint8_t code, uint8_t reason,
> + void *user_data)
> +{
> + bap_stop_complete(stream, code, reason, user_data);
> +}
> +
> static DBusMessage *release(DBusConnection *conn, DBusMessage *msg,
> void *data)
> {
> struct media_transport *transport = data;
> struct media_owner *owner = transport->owner;
> + struct bap_transport *bap = transport->data;
> const char *sender;
> struct media_request *req;
> guint id;
> @@ -642,6 +669,11 @@ static DBusMessage *release(DBusConnection *conn, DBusMessage *msg,
> req = media_request_create(msg, id);
> media_owner_add(owner, req);
>
> + if (bt_bap_stream_get_type(bap->stream) ==
> + BT_BAP_STREAM_TYPE_BCAST) {
> + bap_disable_complete(bap->stream, 0x00, 0x00, owner);
> + }
> +
> return NULL;
> }
>
> @@ -1370,32 +1402,6 @@ static guint resume_bap(struct media_transport *transport,
> return id;
> }
>
> -static void bap_stop_complete(struct bt_bap_stream *stream,
> - uint8_t code, uint8_t reason,
> - void *user_data)
> -{
> - struct media_owner *owner = user_data;
> - struct media_request *req = owner->pending;
> - struct media_transport *transport = owner->transport;
> -
> - /* Release always succeeds */
> - if (req) {
> - req->id = 0;
> - media_request_reply(req, 0);
> - media_owner_remove(owner);
> - }
> -
> - transport_set_state(transport, TRANSPORT_STATE_IDLE);
> - media_transport_remove_owner(transport);
> -}
> -
> -static void bap_disable_complete(struct bt_bap_stream *stream,
> - uint8_t code, uint8_t reason,
> - void *user_data)
> -{
> - bap_stop_complete(stream, code, reason, user_data);
> -}
> -
> static guint suspend_bap(struct media_transport *transport,
> struct media_owner *owner)
> {
> @@ -1499,9 +1505,12 @@ static void bap_state_changed(struct bt_bap_stream *stream, uint8_t old_state,
> return;
> break;
> case BT_BAP_STREAM_STATE_STREAMING:
> - if (bt_bap_stream_io_dir(stream) == BT_BAP_BCAST_SOURCE)
This change is maybe not intended, seems to run update_bcast_qos also
for ucast?
> bap_update_bcast_qos(transport);
> break;
> + case BT_BAP_STREAM_STATE_RELEASING:
> + if (bt_bap_stream_io_dir(stream) == BT_BAP_BCAST_SINK)
> + return;
> + break;
> }
>
> io = bt_bap_stream_get_io(stream);