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.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
  • Loading branch information
Thalley committed Jun 18, 2024
1 parent 1796430 commit 20bfc6f
Show file tree
Hide file tree
Showing 18 changed files with 1,038 additions and 79 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 @@ -291,6 +291,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 @@ -358,7 +361,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
2 changes: 1 addition & 1 deletion subsys/bluetooth/audio/bap_unicast_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,7 @@ static void unicast_client_ep_qos_state(struct bt_bap_ep *ep, struct net_buf_sim
const struct bt_bap_stream_ops *ops;
struct bt_ascs_ase_status_qos *qos;
struct bt_bap_stream *stream;

LOG_ERR("A");
ep->receiver_ready = false;

if (buf->len < sizeof(*qos)) {
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 20bfc6f

Please sign in to comment.