Skip to content

Commit fa4f2ff

Browse files
Thalleyaescolar
authored andcommitted
Bluetooth: CAP: Add support for doing just disable for unicast stop
The unicast_stop function is changed to primarily do a BAP disable instead of a release, with optional support for releasing the streams once they have been disabled. This also adds unittests for the procedure which also allow us to remove the invalid param testing from the BSIM tests. Signed-off-by: Emil Gydesen <[email protected]>
1 parent ff34d57 commit fa4f2ff

File tree

17 files changed

+1022
-125
lines changed

17 files changed

+1022
-125
lines changed

include/zephyr/bluetooth/audio/cap.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,9 @@ struct bt_cap_unicast_audio_stop_param {
312312

313313
/** Array of streams to stop */
314314
struct bt_cap_stream **streams;
315+
316+
/** Whether to release the streams after they have stopped */
317+
bool release;
315318
};
316319

317320
/**
@@ -379,7 +382,10 @@ int bt_cap_initiator_unicast_audio_update(const struct bt_cap_unicast_audio_upda
379382
*
380383
* @param param Stop parameters.
381384
*
382-
* @return 0 on success or negative error value on failure.
385+
* @return 0 on success
386+
* @retval -EBUSY if a CAP procedure is already in progress
387+
* @retval -EINVAL if any parameter is invalid
388+
* @retval -EALREADY if no state changes will occur
383389
*/
384390
int bt_cap_initiator_unicast_audio_stop(const struct bt_cap_unicast_audio_stop_param *param);
385391

subsys/bluetooth/audio/bap_stream.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ void bt_bap_stream_detach(struct bt_bap_stream *stream)
509509
{
510510
const bool is_broadcast = bt_bap_stream_is_broadcast(stream);
511511

512-
LOG_DBG("stream %p", stream);
512+
LOG_DBG("stream %p conn %p ep %p", stream, (void *)stream->conn, (void *)stream->ep);
513513

514514
if (stream->conn != NULL) {
515515
bt_conn_unref(stream->conn);
@@ -587,7 +587,7 @@ int bt_bap_stream_config(struct bt_conn *conn, struct bt_bap_stream *stream, str
587587
codec_cfg, codec_cfg ? codec_cfg->id : 0, codec_cfg ? codec_cfg->cid : 0,
588588
codec_cfg ? codec_cfg->vid : 0);
589589

590-
CHECKIF(conn == NULL || stream == NULL || codec_cfg == NULL) {
590+
CHECKIF(conn == NULL || stream == NULL || codec_cfg == NULL || ep == NULL) {
591591
LOG_DBG("NULL value(s) supplied)");
592592
return -EINVAL;
593593
}

subsys/bluetooth/audio/cap_common.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@ void bt_cap_common_set_subproc(enum bt_cap_common_subproc_type subproc_type)
6464
active_proc.subproc_type = subproc_type;
6565
}
6666

67+
bool bt_cap_common_proc_is_type(enum bt_cap_common_proc_type proc_type)
68+
{
69+
return active_proc.proc_type == proc_type;
70+
}
71+
6772
bool bt_cap_common_subproc_is_type(enum bt_cap_common_subproc_type subproc_type)
6873
{
6974
return active_proc.subproc_type == subproc_type;
@@ -122,7 +127,12 @@ void bt_cap_common_abort_proc(struct bt_conn *conn, int err)
122127
return;
123128
}
124129

130+
#if defined(CONFIG_BT_CAP_INITIATOR_UNICAST)
131+
LOG_DBG("Aborting proc %d with subproc %d for %p: %d", active_proc.proc_type,
132+
active_proc.subproc_type, (void *)conn, err);
133+
#else /* !CONFIG_BT_CAP_INITIATOR_UNICAST */
125134
LOG_DBG("Aborting proc %d for %p: %d", active_proc.proc_type, (void *)conn, err);
135+
#endif /* CONFIG_BT_CAP_INITIATOR_UNICAST */
126136

127137
active_proc.err = err;
128138
active_proc.failed_conn = conn;

0 commit comments

Comments
 (0)