From: Silviu Florian Barbulescu <[email protected]>
Update transport acquire/release flow for BAP broadcast source to
fix failure on transport release, and second acquire
Silviu Florian Barbulescu (3):
shared/bap:Update stream enable/disable flow bcast source
transport: Update transport release flow for broadcast source
bap:Update transport acquire/release flow for bcast source
profiles/audio/bap.c | 16 +++---
profiles/audio/transport.c | 63 +++++++++++++----------
src/shared/bap.c | 100 ++++++++++++++++++++++++++-----------
3 files changed, 116 insertions(+), 63 deletions(-)
base-commit: ae9bf50a27922f2f62a465b62800e90f0fba7831
--
2.39.2
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)
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);
--
2.39.2
Hello:
This series was applied to bluetooth/bluez.git (master)
by Luiz Augusto von Dentz <[email protected]>:
On Mon, 2 Oct 2023 18:33:49 +0300 you wrote:
> From: Silviu Florian Barbulescu <[email protected]>
>
> Update transport acquire/release flow for BAP broadcast source to
> fix failure on transport release, and second acquire
>
> Silviu Florian Barbulescu (3):
> shared/bap:Update stream enable/disable flow bcast source
> transport: Update transport release flow for broadcast source
> bap:Update transport acquire/release flow for bcast source
>
> [...]
Here is the summary with links:
- [v2,1/3] shared/bap:Update stream enable/disable flow bcast src
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=7a79ff88fd95
- [v2,2/3] transport: Update transport release flow for bcast src
(no matching commit)
- [v2,3/3] bap:Update transport acquire/release flow for bcast src
(no matching commit)
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
From: Silviu Florian Barbulescu <[email protected]>
Update stream enable/disable flow for BAP broadcast source
---
src/shared/bap.c | 100 +++++++++++++++++++++++++++++++++--------------
1 file changed, 70 insertions(+), 30 deletions(-)
diff --git a/src/shared/bap.c b/src/shared/bap.c
index 9e9ea1472..925501c48 100644
--- a/src/shared/bap.c
+++ b/src/shared/bap.c
@@ -1331,6 +1331,11 @@ static void stream_set_state_broadcast(struct bt_bap_stream *stream,
ep->old_state = ep->state;
ep->state = state;
+ DBG(bap, "stream %p dir 0x%02x: %s -> %s", stream,
+ bt_bap_stream_get_dir(stream),
+ bt_bap_stream_statestr(stream->ep->old_state),
+ bt_bap_stream_statestr(stream->ep->state));
+
bt_bap_ref(bap);
for (entry = queue_get_entries(bap->state_cbs); entry;
@@ -1347,6 +1352,9 @@ static void stream_set_state_broadcast(struct bt_bap_stream *stream,
case BT_ASCS_ASE_STATE_IDLE:
bap_stream_detach(stream);
break;
+ case BT_ASCS_ASE_STATE_RELEASING:
+ bap_stream_io_detach(stream);
+ break;
}
bt_bap_unref(bap);
@@ -1492,7 +1500,12 @@ static void ep_config_cb(struct bt_bap_stream *stream, int err)
return;
if (bt_bap_stream_get_type(stream) == BT_BAP_STREAM_TYPE_BCAST) {
- stream_set_state_broadcast(stream, BT_BAP_STREAM_STATE_CONFIG);
+ if (bt_bap_stream_io_dir(stream) == BT_BAP_BCAST_SINK)
+ stream_set_state_broadcast(stream,
+ BT_BAP_STREAM_STATE_QOS);
+ else if (bt_bap_stream_io_dir(stream) == BT_BAP_BCAST_SOURCE)
+ stream_set_state_broadcast(stream,
+ BT_BAP_STREAM_STATE_CONFIG);
return;
}
@@ -4914,8 +4927,13 @@ unsigned int bt_bap_stream_enable(struct bt_bap_stream *stream,
queue_foreach(stream->links, bap_stream_enable_link, metadata);
break;
case BT_BAP_STREAM_TYPE_BCAST:
- stream_set_state_broadcast(stream,
- BT_BAP_STREAM_STATE_STREAMING);
+ if (bt_bap_stream_io_dir(stream) == BT_BAP_BCAST_SINK)
+ stream_set_state_broadcast(stream,
+ BT_BAP_STREAM_STATE_CONFIG);
+ else if (bt_bap_stream_io_dir(stream) == BT_BAP_BCAST_SOURCE)
+ stream_set_state_broadcast(stream,
+ BT_BAP_STREAM_STATE_STREAMING);
+
return 1;
}
@@ -4933,30 +4951,40 @@ unsigned int bt_bap_stream_start(struct bt_bap_stream *stream,
if (!bap_stream_valid(stream))
return 0;
- if (!stream->client) {
+ switch (bt_bap_stream_get_type(stream)) {
+ case BT_BAP_STREAM_TYPE_UCAST:
+ if (!stream->client) {
+ if (stream->ep->dir == BT_BAP_SINK)
+ stream_start(stream, NULL);
+ return 0;
+ }
+
if (stream->ep->dir == BT_BAP_SINK)
- stream_start(stream, NULL);
- return 0;
- }
+ return 0;
- if (stream->ep->dir == BT_BAP_SINK)
- return 0;
+ memset(&start, 0, sizeof(start));
- memset(&start, 0, sizeof(start));
+ start.ase = stream->ep->id;
- start.ase = stream->ep->id;
+ iov.iov_base = &start;
+ iov.iov_len = sizeof(start);
- iov.iov_base = &start;
- iov.iov_len = sizeof(start);
+ req = bap_req_new(stream, BT_ASCS_START,
+ &iov, 1, func, user_data);
- req = bap_req_new(stream, BT_ASCS_START, &iov, 1, func, user_data);
+ if (!bap_queue_req(stream->bap, req)) {
+ bap_req_free(req);
+ return 0;
+ }
- if (!bap_queue_req(stream->bap, req)) {
- bap_req_free(req);
- return 0;
+ return req->id;
+ case BT_BAP_STREAM_TYPE_BCAST:
+ stream_set_state_broadcast(stream,
+ BT_BAP_STREAM_STATE_STREAMING);
+ return 1;
}
- return req->id;
+ return 0;
}
static void bap_stream_disable_link(void *data, void *user_data)
@@ -4996,24 +5024,36 @@ unsigned int bt_bap_stream_disable(struct bt_bap_stream *stream,
return 0;
}
- memset(&disable, 0, sizeof(disable));
+ switch (bt_bap_stream_get_type(stream)) {
+ case BT_BAP_STREAM_TYPE_UCAST:
+ memset(&disable, 0, sizeof(disable));
- disable.ase = stream->ep->id;
+ disable.ase = stream->ep->id;
- iov.iov_base = &disable;
- iov.iov_len = sizeof(disable);
+ iov.iov_base = &disable;
+ iov.iov_len = sizeof(disable);
- req = bap_req_new(stream, BT_ASCS_DISABLE, &iov, 1, func, user_data);
+ req = bap_req_new(stream, BT_ASCS_DISABLE, &iov, 1, func,
+ user_data);
- if (!bap_queue_req(stream->bap, req)) {
- bap_req_free(req);
- return 0;
- }
+ if (!bap_queue_req(stream->bap, req)) {
+ bap_req_free(req);
+ return 0;
+ }
- if (disable_links)
- queue_foreach(stream->links, bap_stream_disable_link, NULL);
+ if (disable_links)
+ queue_foreach(stream->links, bap_stream_disable_link,
+ NULL);
- return req->id;
+ return req->id;
+
+ case BT_BAP_STREAM_TYPE_BCAST:
+ stream_set_state_broadcast(stream,
+ BT_BAP_STREAM_STATE_RELEASING);
+ return 1;
+ }
+
+ return 0;
}
unsigned int bt_bap_stream_stop(struct bt_bap_stream *stream,
--
2.39.2