diff mbox series

[BlueZ,2/4] shared/bap: move bcast configure finish out from set_user_data

Message ID 4a7871ce4bffa5b39adcd4b710c0a225492ef267.1699802164.git.pav@iki.fi
State New
Headers show
Series [BlueZ,1/4] shared/bap: add bt_bap_stream_config_update for updating QoS choice | expand

Commit Message

Pauli Virtanen Nov. 12, 2023, 4 p.m. UTC
Creating transports for broadcast streams should not be a side effect of
bt_bap_stream_set_user_data, but via a separate function.

Move that to new function bt_bap_stream_bcast_configured.
---

Notes:
    This might be something that should be done in bt_bap_stream_config(),
    however that is sometimes called when it appears creating transports is
    not intended. Possibly these calls should use
    bt_bap_stream_config_update instead.
    
    The broadcast setup logic probably can be cleaned up here, but I don't
    currently have a setup to test it, so this is minimal cleanup.

 src/shared/bap.c | 19 +++++++++++++++----
 src/shared/bap.h |  2 ++
 2 files changed, 17 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/src/shared/bap.c b/src/shared/bap.c
index d90e39f7c..085a46216 100644
--- a/src/shared/bap.c
+++ b/src/shared/bap.c
@@ -1522,6 +1522,21 @@  static uint8_t stream_config(struct bt_bap_stream *stream, struct iovec *cc,
 	return 0;
 }
 
+int bt_bap_stream_bcast_configured(struct bt_bap_stream *stream)
+{
+	if (!stream)
+		return -EINVAL;
+	if (!stream->lpac->ops || !stream->lpac->ops->config)
+		return -EINVAL;
+	if (bt_bap_stream_get_type(stream) != BT_BAP_STREAM_TYPE_BCAST)
+		return -EINVAL;
+
+	stream->lpac->ops->config(stream, stream->cc, &stream->qos,
+			ep_config_cb, stream->lpac->user_data);
+
+	return 0;
+}
+
 static uint8_t ep_config(struct bt_bap_endpoint *ep, struct bt_bap *bap,
 				 struct bt_ascs_config *req,
 				 struct iovec *iov, struct iovec *rsp)
@@ -4748,10 +4763,6 @@  bool bt_bap_stream_set_user_data(struct bt_bap_stream *stream, void *user_data)
 
 	stream->user_data = user_data;
 
-	if (bt_bap_stream_get_type(stream) == BT_BAP_STREAM_TYPE_BCAST)
-		stream->lpac->ops->config(stream, stream->cc, &stream->qos,
-					ep_config_cb, stream->lpac->user_data);
-
 	return true;
 }
 
diff --git a/src/shared/bap.h b/src/shared/bap.h
index 099c2edd0..0f9ae27b7 100644
--- a/src/shared/bap.h
+++ b/src/shared/bap.h
@@ -263,6 +263,8 @@  unsigned int bt_bap_stream_qos(struct bt_bap_stream *stream,
 					bt_bap_stream_func_t func,
 					void *user_data);
 
+int bt_bap_stream_bcast_configured(struct bt_bap_stream *stream);
+
 unsigned int bt_bap_stream_enable(struct bt_bap_stream *stream,
 					bool enable_links,
 					struct iovec *metadata,