Skip to content

Commit

Permalink
Bluetooth: CAP: Add support for doing just disable for unicast stop
Browse files Browse the repository at this point in the history
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 <emil.gydesen@nordicsemi.no>
  • Loading branch information
Thalley committed Sep 2, 2024
1 parent f887f3c commit 01b5556
Show file tree
Hide file tree
Showing 17 changed files with 1,022 additions and 125 deletions.
8 changes: 7 additions & 1 deletion include/zephyr/bluetooth/audio/cap.h
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,9 @@ struct bt_cap_unicast_audio_stop_param {

/** Array of streams to stop */
struct bt_cap_stream **streams;

/** Whether to release the streams after they have stopped */
bool release;
};

/**
Expand Down Expand Up @@ -379,7 +382,10 @@ int bt_cap_initiator_unicast_audio_update(const struct bt_cap_unicast_audio_upda
*
* @param param Stop parameters.
*
* @return 0 on success or negative error value on failure.
* @return 0 on success
* @retval -EBUSY if a CAP procedure is already in progress
* @retval -EINVAL if any parameter is invalid
* @retval -EALREADY if no state changes will occur
*/
int bt_cap_initiator_unicast_audio_stop(const struct bt_cap_unicast_audio_stop_param *param);

Expand Down
4 changes: 2 additions & 2 deletions subsys/bluetooth/audio/bap_stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ void bt_bap_stream_detach(struct bt_bap_stream *stream)
{
const bool is_broadcast = bt_bap_stream_is_broadcast(stream);

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

if (stream->conn != NULL) {
bt_conn_unref(stream->conn);
Expand Down Expand Up @@ -534,7 +534,7 @@ int bt_bap_stream_config(struct bt_conn *conn, struct bt_bap_stream *stream, str
codec_cfg, codec_cfg ? codec_cfg->id : 0, codec_cfg ? codec_cfg->cid : 0,
codec_cfg ? codec_cfg->vid : 0);

CHECKIF(conn == NULL || stream == NULL || codec_cfg == NULL) {
CHECKIF(conn == NULL || stream == NULL || codec_cfg == NULL || ep == NULL) {
LOG_DBG("NULL value(s) supplied)");
return -EINVAL;
}
Expand Down
10 changes: 10 additions & 0 deletions subsys/bluetooth/audio/cap_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ void bt_cap_common_set_subproc(enum bt_cap_common_subproc_type subproc_type)
active_proc.subproc_type = subproc_type;
}

bool bt_cap_common_proc_is_type(enum bt_cap_common_proc_type proc_type)
{
return active_proc.proc_type == proc_type;
}

bool bt_cap_common_subproc_is_type(enum bt_cap_common_subproc_type subproc_type)
{
return active_proc.subproc_type == subproc_type;
Expand Down Expand Up @@ -122,7 +127,12 @@ void bt_cap_common_abort_proc(struct bt_conn *conn, int err)
return;
}

#if defined(CONFIG_BT_CAP_INITIATOR_UNICAST)
LOG_DBG("Aborting proc %d with subproc %d for %p: %d", active_proc.proc_type,
active_proc.subproc_type, (void *)conn, err);
#else /* !CONFIG_BT_CAP_INITIATOR_UNICAST */
LOG_DBG("Aborting proc %d for %p: %d", active_proc.proc_type, (void *)conn, err);
#endif /* CONFIG_BT_CAP_INITIATOR_UNICAST */

active_proc.err = err;
active_proc.failed_conn = conn;
Expand Down
Loading

0 comments on commit 01b5556

Please sign in to comment.