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 (mailing list archive)
State New, archived
Headers show
Series [BlueZ,1/4] shared/bap: add bt_bap_stream_config_update for updating QoS choice | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
tedd_an/CheckPatch success CheckPatch PASS
tedd_an/GitLint fail WARNING: I3 - ignore-body-lines: gitlint will be switching from using Python regex 'match' (match beginning) to 'search' (match anywhere) semantics. Please review your ignore-body-lines.regex option accordingly. To remove this warning, set general.regex-style-search=True. More details: https://jorisroovers.github.io/gitlint/configuration/#regex-style-search 14: B2 Line has trailing whitespace: " "
tedd_an/IncrementalBuild success Incremental Build PASS

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,