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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 --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,
-- 
2.41.0





[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux