Bluetooth: CAP: Remove unicast group param from unicast_audio_start

Since we can always lookup the group from the streams, the
group parameter had no purpose.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This commit is contained in:
Emil Gydesen 2024-01-17 15:25:22 +01:00 committed by David Leach
commit f35e9871d5
8 changed files with 65 additions and 106 deletions

View file

@ -76,8 +76,6 @@ struct bt_cap_initiator_cb {
/** /**
* @brief Callback for bt_cap_initiator_unicast_audio_start(). * @brief Callback for bt_cap_initiator_unicast_audio_start().
* *
* @param unicast_group The unicast group pointer supplied to
* bt_cap_initiator_unicast_audio_start().
* @param err 0 if success, BT_GATT_ERR() with a * @param err 0 if success, BT_GATT_ERR() with a
* specific ATT (BT_ATT_ERR_*) error code or -ECANCELED if cancelled * specific ATT (BT_ATT_ERR_*) error code or -ECANCELED if cancelled
* by bt_cap_initiator_unicast_audio_cancel(). * by bt_cap_initiator_unicast_audio_cancel().
@ -85,8 +83,7 @@ struct bt_cap_initiator_cb {
* occurred. NULL if @p err is 0 or if cancelled by * occurred. NULL if @p err is 0 or if cancelled by
* bt_cap_initiator_unicast_audio_cancel() * bt_cap_initiator_unicast_audio_cancel()
*/ */
void (*unicast_start_complete)(struct bt_bap_unicast_group *unicast_group, void (*unicast_start_complete)(int err, struct bt_conn *conn);
int err, struct bt_conn *conn);
/** /**
* @brief Callback for bt_cap_initiator_unicast_audio_update(). * @brief Callback for bt_cap_initiator_unicast_audio_update().
@ -103,14 +100,6 @@ struct bt_cap_initiator_cb {
/** /**
* @brief Callback for bt_cap_initiator_unicast_audio_stop(). * @brief Callback for bt_cap_initiator_unicast_audio_stop().
* *
* If @p err is 0, then @p unicast_group has been deleted and can no
* longer be used.
*
* If @p err is not 0 and @p conn is NULL, then the deletion of the
* @p unicast_group failed with @p err as the error.
*
* @param unicast_group The unicast group pointer supplied to
* bt_cap_initiator_unicast_audio_stop().
* @param err 0 if success, BT_GATT_ERR() with a * @param err 0 if success, BT_GATT_ERR() with a
* specific ATT (BT_ATT_ERR_*) error code or -ECANCELED if cancelled * specific ATT (BT_ATT_ERR_*) error code or -ECANCELED if cancelled
* by bt_cap_initiator_unicast_audio_cancel(). * by bt_cap_initiator_unicast_audio_cancel().
@ -118,8 +107,7 @@ struct bt_cap_initiator_cb {
* occurred. NULL if @p err is 0 or if cancelled by * occurred. NULL if @p err is 0 or if cancelled by
* bt_cap_initiator_unicast_audio_cancel() * bt_cap_initiator_unicast_audio_cancel()
*/ */
void (*unicast_stop_complete)(struct bt_bap_unicast_group *unicast_group, void (*unicast_stop_complete)(int err, struct bt_conn *conn);
int err, struct bt_conn *conn);
#endif /* CONFIG_BT_BAP_UNICAST_CLIENT */ #endif /* CONFIG_BT_BAP_UNICAST_CLIENT */
}; };
@ -206,6 +194,7 @@ int bt_cap_stream_send(struct bt_cap_stream *stream, struct net_buf *buf, uint16
*/ */
int bt_cap_stream_get_tx_sync(struct bt_cap_stream *stream, struct bt_iso_tx_info *info); int bt_cap_stream_get_tx_sync(struct bt_cap_stream *stream, struct bt_iso_tx_info *info);
/** Stream specific parameters for the bt_cap_initiator_unicast_audio_start() function */
struct bt_cap_unicast_audio_start_stream_param { struct bt_cap_unicast_audio_start_stream_param {
/** Coordinated or ad-hoc set member. */ /** Coordinated or ad-hoc set member. */
union bt_cap_set_member member; union bt_cap_set_member member;
@ -226,6 +215,7 @@ struct bt_cap_unicast_audio_start_stream_param {
struct bt_audio_codec_cfg *codec_cfg; struct bt_audio_codec_cfg *codec_cfg;
}; };
/** Parameters for the bt_cap_initiator_unicast_audio_start() function */
struct bt_cap_unicast_audio_start_param { struct bt_cap_unicast_audio_start_param {
/** The type of the set. */ /** The type of the set. */
enum bt_cap_set_type type; enum bt_cap_set_type type;
@ -272,13 +262,11 @@ int bt_cap_initiator_register_cb(const struct bt_cap_initiator_cb *cb);
* @kconfig{CONFIG_BT_BAP_UNICAST_CLIENT} must be enabled for this function * @kconfig{CONFIG_BT_BAP_UNICAST_CLIENT} must be enabled for this function
* to be enabled. * to be enabled.
* *
* @param[in] param Parameters to start the audio streams. * @param param Parameters to start the audio streams.
* @param[out] unicast_group Pointer to the unicast group.
* *
* @return 0 on success or negative error value on failure. * @return 0 on success or negative error value on failure.
*/ */
int bt_cap_initiator_unicast_audio_start(const struct bt_cap_unicast_audio_start_param *param, int bt_cap_initiator_unicast_audio_start(const struct bt_cap_unicast_audio_start_param *param);
struct bt_bap_unicast_group *unicast_group);
/** /**
* @brief Update unicast audio streams. * @brief Update unicast audio streams.

View file

@ -119,8 +119,7 @@ static void cap_discovery_complete_cb(struct bt_conn *conn, int err,
k_sem_give(&sem_cas_discovery); k_sem_give(&sem_cas_discovery);
} }
static void unicast_start_complete_cb(struct bt_bap_unicast_group *unicast_group, static void unicast_start_complete_cb(int err, struct bt_conn *conn)
int err, struct bt_conn *conn)
{ {
if (err != 0) { if (err != 0) {
printk("Failed to start (failing conn %p): %d", conn, err); printk("Failed to start (failing conn %p): %d", conn, err);
@ -138,8 +137,7 @@ static void unicast_update_complete_cb(int err, struct bt_conn *conn)
} }
} }
static void unicast_stop_complete_cb(struct bt_bap_unicast_group *unicast_group, int err, static void unicast_stop_complete_cb(int err, struct bt_conn *conn)
struct bt_conn *conn)
{ {
if (err != 0) { if (err != 0) {
printk("Failed to stop (failing conn %p): %d", conn, err); printk("Failed to stop (failing conn %p): %d", conn, err);
@ -330,7 +328,7 @@ static int unicast_group_create(struct bt_bap_unicast_group **out_unicast_group)
return err; return err;
} }
static int unicast_audio_start(struct bt_conn *conn, struct bt_bap_unicast_group *unicast_group) static int unicast_audio_start(struct bt_conn *conn)
{ {
int err = 0; int err = 0;
struct bt_cap_unicast_audio_start_stream_param stream_param; struct bt_cap_unicast_audio_start_stream_param stream_param;
@ -345,7 +343,7 @@ static int unicast_audio_start(struct bt_conn *conn, struct bt_bap_unicast_group
stream_param.ep = unicast_sink_eps[0]; stream_param.ep = unicast_sink_eps[0];
stream_param.codec_cfg = &unicast_preset_48_2_1.codec_cfg; stream_param.codec_cfg = &unicast_preset_48_2_1.codec_cfg;
err = bt_cap_initiator_unicast_audio_start(&param, unicast_group); err = bt_cap_initiator_unicast_audio_start(&param);
if (err != 0) { if (err != 0) {
printk("Failed to start unicast audio: %d\n", err); printk("Failed to start unicast audio: %d\n", err);
return err; return err;
@ -457,7 +455,7 @@ int cap_initiator_setup(struct bt_conn *conn)
return err; return err;
} }
err = unicast_audio_start(conn, unicast_group); err = unicast_audio_start(conn);
if (err != 0) { if (err != 0) {
return err; return err;
} }

View file

@ -332,9 +332,10 @@ int bt_cap_initiator_unicast_discover(struct bt_conn *conn)
return bt_cap_common_discover(conn, bt_cap_initiator_discover_complete); return bt_cap_common_discover(conn, bt_cap_initiator_discover_complete);
} }
static bool valid_unicast_audio_start_param(const struct bt_cap_unicast_audio_start_param *param, static bool valid_unicast_audio_start_param(const struct bt_cap_unicast_audio_start_param *param)
struct bt_bap_unicast_group *unicast_group)
{ {
struct bt_bap_unicast_group *unicast_group = NULL;
CHECKIF(param == NULL) { CHECKIF(param == NULL) {
LOG_DBG("param is NULL"); LOG_DBG("param is NULL");
return false; return false;
@ -410,9 +411,15 @@ static bool valid_unicast_audio_start_param(const struct bt_cap_unicast_audio_st
return false; return false;
} }
CHECKIF(bap_stream->group != unicast_group) { /* Use the group of the first stream for comparison */
LOG_DBG("param->streams[%zu] is not in this group %p", i, unicast_group); if (unicast_group == NULL) {
return false; unicast_group = bap_stream->group;
} else {
CHECKIF(bap_stream->group != unicast_group) {
LOG_DBG("param->streams[%zu] is not in this group %p", i,
unicast_group);
return false;
}
} }
for (size_t j = 0U; j < i; j++) { for (size_t j = 0U; j < i; j++) {
@ -433,12 +440,10 @@ static bool valid_unicast_audio_start_param(const struct bt_cap_unicast_audio_st
static void cap_initiator_unicast_audio_proc_complete(void) static void cap_initiator_unicast_audio_proc_complete(void)
{ {
struct bt_cap_common_proc *active_proc = bt_cap_common_get_active_proc(); struct bt_cap_common_proc *active_proc = bt_cap_common_get_active_proc();
struct bt_bap_unicast_group *unicast_group;
enum bt_cap_common_proc_type proc_type; enum bt_cap_common_proc_type proc_type;
struct bt_conn *failed_conn; struct bt_conn *failed_conn;
int err; int err;
unicast_group = active_proc->unicast_group;
failed_conn = active_proc->failed_conn; failed_conn = active_proc->failed_conn;
err = active_proc->err; err = active_proc->err;
proc_type = active_proc->proc_type; proc_type = active_proc->proc_type;
@ -451,7 +456,7 @@ static void cap_initiator_unicast_audio_proc_complete(void)
switch (proc_type) { switch (proc_type) {
case BT_CAP_COMMON_PROC_TYPE_START: case BT_CAP_COMMON_PROC_TYPE_START:
if (cap_cb->unicast_start_complete != NULL) { if (cap_cb->unicast_start_complete != NULL) {
cap_cb->unicast_start_complete(unicast_group, err, failed_conn); cap_cb->unicast_start_complete(err, failed_conn);
} }
break; break;
case BT_CAP_COMMON_PROC_TYPE_UPDATE: case BT_CAP_COMMON_PROC_TYPE_UPDATE:
@ -461,7 +466,7 @@ static void cap_initiator_unicast_audio_proc_complete(void)
break; break;
case BT_CAP_COMMON_PROC_TYPE_STOP: case BT_CAP_COMMON_PROC_TYPE_STOP:
if (cap_cb->unicast_stop_complete != NULL) { if (cap_cb->unicast_stop_complete != NULL) {
cap_cb->unicast_stop_complete(unicast_group, err, failed_conn); cap_cb->unicast_stop_complete(err, failed_conn);
} }
break; break;
case BT_CAP_COMMON_PROC_TYPE_NONE: case BT_CAP_COMMON_PROC_TYPE_NONE:
@ -533,28 +538,18 @@ static int cap_initiator_unicast_audio_configure(
return err; return err;
} }
int bt_cap_initiator_unicast_audio_start(const struct bt_cap_unicast_audio_start_param *param, int bt_cap_initiator_unicast_audio_start(const struct bt_cap_unicast_audio_start_param *param)
struct bt_bap_unicast_group *unicast_group)
{ {
struct bt_cap_common_proc *active_proc = bt_cap_common_get_active_proc();
if (bt_cap_common_proc_is_active()) { if (bt_cap_common_proc_is_active()) {
LOG_DBG("A CAP procedure is already in progress"); LOG_DBG("A CAP procedure is already in progress");
return -EBUSY; return -EBUSY;
} }
CHECKIF(unicast_group == NULL) { if (!valid_unicast_audio_start_param(param)) {
LOG_DBG("unicast_group is NULL");
return -EINVAL; return -EINVAL;
} }
if (!valid_unicast_audio_start_param(param, unicast_group)) {
return -EINVAL;
}
active_proc->unicast_group = unicast_group;
return cap_initiator_unicast_audio_configure(param); return cap_initiator_unicast_audio_configure(param);
} }
@ -1119,7 +1114,6 @@ int bt_cap_initiator_unicast_audio_stop(struct bt_bap_unicast_group *unicast_gro
} }
bt_cap_common_start_proc(BT_CAP_COMMON_PROC_TYPE_STOP, stream_cnt); bt_cap_common_start_proc(BT_CAP_COMMON_PROC_TYPE_STOP, stream_cnt);
active_proc->unicast_group = unicast_group;
bt_cap_common_set_subproc(BT_CAP_COMMON_SUBPROC_TYPE_RELEASE); bt_cap_common_set_subproc(BT_CAP_COMMON_SUBPROC_TYPE_RELEASE);

View file

@ -111,7 +111,6 @@ struct bt_cap_common_proc {
struct bt_conn *failed_conn; struct bt_conn *failed_conn;
struct bt_cap_common_proc_param proc_param; struct bt_cap_common_proc_param proc_param;
#if defined(CONFIG_BT_CAP_INITIATOR_UNICAST) #if defined(CONFIG_BT_CAP_INITIATOR_UNICAST)
struct bt_bap_unicast_group *unicast_group;
enum bt_cap_common_subproc_type subproc_type; enum bt_cap_common_subproc_type subproc_type;
#endif /* CONFIG_BT_CAP_INITIATOR_UNICAST */ #endif /* CONFIG_BT_CAP_INITIATOR_UNICAST */
}; };

View file

@ -36,8 +36,7 @@ static void cap_discover_cb(struct bt_conn *conn, int err,
csis_inst == NULL ? "" : " with CSIS"); csis_inst == NULL ? "" : " with CSIS");
} }
static void cap_unicast_start_complete_cb(struct bt_bap_unicast_group *unicast_group, static void cap_unicast_start_complete_cb(int err, struct bt_conn *conn)
int err, struct bt_conn *conn)
{ {
if (err == -ECANCELED) { if (err == -ECANCELED) {
shell_print(ctx_shell, "Unicast start was cancelled for conn %p", conn); shell_print(ctx_shell, "Unicast start was cancelled for conn %p", conn);
@ -60,31 +59,23 @@ static void unicast_update_complete_cb(int err, struct bt_conn *conn)
} }
} }
static void unicast_stop_complete_cb(struct bt_bap_unicast_group *unicast_group, int err, static void unicast_stop_complete_cb(int err, struct bt_conn *conn)
struct bt_conn *conn)
{ {
if (default_unicast_group != unicast_group) {
/* ignore */
return;
}
if (err == -ECANCELED) { if (err == -ECANCELED) {
shell_print(ctx_shell, "Unicast stop was cancelled for conn %p", conn); shell_print(ctx_shell, "Unicast stop was cancelled for conn %p", conn);
} else if (err != 0) { } else if (err != 0) {
shell_error(ctx_shell, shell_error(ctx_shell, "Unicast stop failed for conn %p (%d)", conn, err);
"Unicast stop failed for group %p and conn %p (%d)",
unicast_group, conn, err);
} else { } else {
shell_print(ctx_shell, shell_print(ctx_shell, "Unicast stopped completed");
"Unicast stopped for group %p completed",
default_unicast_group);
err = bt_bap_unicast_group_delete(unicast_group); if (default_unicast_group != NULL) {
if (err != 0) { err = bt_bap_unicast_group_delete(default_unicast_group);
shell_error(ctx_shell, "Failed to delete unicast group %p: %d", if (err != 0) {
unicast_group, err); shell_error(ctx_shell, "Failed to delete unicast group %p: %d",
} else { default_unicast_group, err);
default_unicast_group = NULL; } else {
default_unicast_group = NULL;
}
} }
} }
} }
@ -320,7 +311,7 @@ static int cmd_cap_initiator_unicast_start(const struct shell *sh, size_t argc,
shell_print(sh, "Starting %zu streams", start_param.count); shell_print(sh, "Starting %zu streams", start_param.count);
err = bt_cap_initiator_unicast_audio_start(&start_param, default_unicast_group); err = bt_cap_initiator_unicast_audio_start(&start_param);
if (err != 0) { if (err != 0) {
shell_print(sh, "Failed to start unicast audio: %d", err); shell_print(sh, "Failed to start unicast audio: %d", err);
@ -625,7 +616,7 @@ static int cap_ac_unicast_start(const struct bap_unicast_ac_param *param,
start_param.count = stream_cnt; start_param.count = stream_cnt;
start_param.type = BT_CAP_SET_TYPE_AD_HOC; start_param.type = BT_CAP_SET_TYPE_AD_HOC;
return bt_cap_initiator_unicast_audio_start(&start_param, default_unicast_group); return bt_cap_initiator_unicast_audio_start(&start_param);
} }
int cap_ac_unicast(const struct shell *sh, size_t argc, char **argv, int cap_ac_unicast(const struct shell *sh, size_t argc, char **argv,

View file

@ -20,6 +20,8 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME, CONFIG_BTTESTER_LOG_LEVEL);
#include "btp_bap_unicast.h" #include "btp_bap_unicast.h"
#include "btp_bap_broadcast.h" #include "btp_bap_broadcast.h"
static struct btp_bap_unicast_group *u_group;
extern struct bt_csip_set_coordinator_set_member *btp_csip_set_members[CONFIG_BT_MAX_CONN]; extern struct bt_csip_set_coordinator_set_member *btp_csip_set_members[CONFIG_BT_MAX_CONN];
static struct bt_bap_stream *stream_unicast_to_bap(struct btp_bap_unicast_stream *stream) static struct bt_bap_stream *stream_unicast_to_bap(struct btp_bap_unicast_stream *stream)
@ -95,20 +97,19 @@ static void btp_send_cap_unicast_stop_completed_ev(uint8_t cig_id, uint8_t statu
tester_event(BTP_SERVICE_ID_CAP, BTP_CAP_EV_UNICAST_STOP_COMPLETED, &ev, sizeof(ev)); tester_event(BTP_SERVICE_ID_CAP, BTP_CAP_EV_UNICAST_STOP_COMPLETED, &ev, sizeof(ev));
} }
static void unicast_start_complete_cb(struct bt_bap_unicast_group *group, static void unicast_start_complete_cb(int err, struct bt_conn *conn)
int err, struct bt_conn *conn)
{ {
LOG_DBG(""); LOG_DBG("");
if (err != 0) { if (err != 0) {
LOG_DBG("Failed to unicast-start, err %d", err); LOG_DBG("Failed to unicast-start, err %d", err);
btp_send_cap_unicast_start_completed_ev(group->index, btp_send_cap_unicast_start_completed_ev(u_group->cig->index,
BTP_CAP_UNICAST_START_STATUS_FAILED); BTP_CAP_UNICAST_START_STATUS_FAILED);
return; return;
} }
btp_send_cap_unicast_start_completed_ev(group->index, btp_send_cap_unicast_start_completed_ev(u_group->cig->index,
BTP_CAP_UNICAST_START_STATUS_SUCCESS); BTP_CAP_UNICAST_START_STATUS_SUCCESS);
} }
@ -121,20 +122,19 @@ static void unicast_update_complete_cb(int err, struct bt_conn *conn)
} }
} }
static void unicast_stop_complete_cb(struct bt_bap_unicast_group *group, int err, static void unicast_stop_complete_cb(int err, struct bt_conn *conn)
struct bt_conn *conn)
{ {
LOG_DBG(""); LOG_DBG("");
if (err != 0) { if (err != 0) {
LOG_DBG("Failed to unicast-stop, err %d", err); LOG_DBG("Failed to unicast-stop, err %d", err);
btp_send_cap_unicast_stop_completed_ev(group->index, btp_send_cap_unicast_stop_completed_ev(u_group->cig->index,
BTP_CAP_UNICAST_START_STATUS_FAILED); BTP_CAP_UNICAST_START_STATUS_FAILED);
return; return;
} }
btp_send_cap_unicast_stop_completed_ev(group->index, btp_send_cap_unicast_stop_completed_ev(u_group->cig->index,
BTP_CAP_UNICAST_START_STATUS_SUCCESS); BTP_CAP_UNICAST_START_STATUS_SUCCESS);
} }
@ -282,7 +282,6 @@ static uint8_t btp_cap_unicast_audio_start(const void *cmd, uint16_t cmd_len,
{ {
int err; int err;
size_t stream_count = 0; size_t stream_count = 0;
struct btp_bap_unicast_group *u_group;
const struct btp_cap_unicast_audio_start_cmd *cp = cmd; const struct btp_cap_unicast_audio_start_cmd *cp = cmd;
struct bt_cap_unicast_audio_start_param start_param; struct bt_cap_unicast_audio_start_param start_param;
struct bt_cap_unicast_audio_start_stream_param stream_params[ struct bt_cap_unicast_audio_start_stream_param stream_params[
@ -326,7 +325,7 @@ static uint8_t btp_cap_unicast_audio_start(const void *cmd, uint16_t cmd_len,
start_param.count = stream_count; start_param.count = stream_count;
start_param.stream_params = stream_params; start_param.stream_params = stream_params;
err = bt_cap_initiator_unicast_audio_start(&start_param, u_group->cig); err = bt_cap_initiator_unicast_audio_start(&start_param);
if (err != 0) { if (err != 0) {
LOG_ERR("Failed to start unicast audio: %d", err); LOG_ERR("Failed to start unicast audio: %d", err);

View file

@ -183,8 +183,7 @@ static void cap_discovery_complete_cb(struct bt_conn *conn, int err,
SET_FLAG(flag_discovered); SET_FLAG(flag_discovered);
} }
static void unicast_start_complete_cb(struct bt_bap_unicast_group *unicast_group, int err, static void unicast_start_complete_cb(int err, struct bt_conn *conn)
struct bt_conn *conn)
{ {
if (err == -ECANCELED) { if (err == -ECANCELED) {
SET_FLAG(flag_start_timeout); SET_FLAG(flag_start_timeout);
@ -206,8 +205,7 @@ static void unicast_update_complete_cb(int err, struct bt_conn *conn)
SET_FLAG(flag_updated); SET_FLAG(flag_updated);
} }
static void unicast_stop_complete_cb(struct bt_bap_unicast_group *unicast_group, int err, static void unicast_stop_complete_cb(int err, struct bt_conn *conn)
struct bt_conn *conn)
{ {
if (err != 0) { if (err != 0) {
FAIL("Failed to stop (failing conn %p): %d", conn, err); FAIL("Failed to stop (failing conn %p): %d", conn, err);
@ -545,18 +543,12 @@ static void unicast_audio_start_inval(struct bt_bap_unicast_group *unicast_group
valid_stream_param.codec_cfg = &unicast_preset_16_2_1.codec_cfg; valid_stream_param.codec_cfg = &unicast_preset_16_2_1.codec_cfg;
/* Test NULL parameters */ /* Test NULL parameters */
err = bt_cap_initiator_unicast_audio_start(NULL, unicast_group); err = bt_cap_initiator_unicast_audio_start(NULL);
if (err == 0) { if (err == 0) {
FAIL("bt_cap_initiator_unicast_audio_start with NULL param did not fail\n"); FAIL("bt_cap_initiator_unicast_audio_start with NULL param did not fail\n");
return; return;
} }
err = bt_cap_initiator_unicast_audio_start(&valid_start_param, NULL);
if (err == 0) {
FAIL("bt_cap_initiator_unicast_audio_start with NULL group did not fail\n");
return;
}
/* Test invalid parameters */ /* Test invalid parameters */
memcpy(&invalid_stream_param, &valid_stream_param, sizeof(valid_stream_param)); memcpy(&invalid_stream_param, &valid_stream_param, sizeof(valid_stream_param));
memcpy(&invalid_start_param, &valid_start_param, sizeof(valid_start_param)); memcpy(&invalid_start_param, &valid_start_param, sizeof(valid_start_param));
@ -564,7 +556,7 @@ static void unicast_audio_start_inval(struct bt_bap_unicast_group *unicast_group
/* Test invalid stream_start parameters */ /* Test invalid stream_start parameters */
invalid_start_param.count = 0U; invalid_start_param.count = 0U;
err = bt_cap_initiator_unicast_audio_start(&invalid_start_param, unicast_group); err = bt_cap_initiator_unicast_audio_start(&invalid_start_param);
if (err == 0) { if (err == 0) {
FAIL("bt_cap_initiator_unicast_audio_start with 0 count did not fail\n"); FAIL("bt_cap_initiator_unicast_audio_start with 0 count did not fail\n");
return; return;
@ -574,7 +566,7 @@ static void unicast_audio_start_inval(struct bt_bap_unicast_group *unicast_group
invalid_start_param.stream_params = &invalid_stream_param; invalid_start_param.stream_params = &invalid_stream_param;
invalid_start_param.stream_params = NULL; invalid_start_param.stream_params = NULL;
err = bt_cap_initiator_unicast_audio_start(&invalid_start_param, unicast_group); err = bt_cap_initiator_unicast_audio_start(&invalid_start_param);
if (err == 0) { if (err == 0) {
FAIL("bt_cap_initiator_unicast_audio_start with NULL stream params did not fail\n"); FAIL("bt_cap_initiator_unicast_audio_start with NULL stream params did not fail\n");
return; return;
@ -585,7 +577,7 @@ static void unicast_audio_start_inval(struct bt_bap_unicast_group *unicast_group
/* Test invalid stream_param parameters */ /* Test invalid stream_param parameters */
invalid_stream_param.member.member = NULL; invalid_stream_param.member.member = NULL;
err = bt_cap_initiator_unicast_audio_start(&invalid_start_param, unicast_group); err = bt_cap_initiator_unicast_audio_start(&invalid_start_param);
if (err == 0) { if (err == 0) {
FAIL("bt_cap_initiator_unicast_audio_start with NULL stream params member did not " FAIL("bt_cap_initiator_unicast_audio_start with NULL stream params member did not "
"fail\n"); "fail\n");
@ -595,7 +587,7 @@ static void unicast_audio_start_inval(struct bt_bap_unicast_group *unicast_group
memcpy(&invalid_stream_param, &valid_stream_param, sizeof(valid_stream_param)); memcpy(&invalid_stream_param, &valid_stream_param, sizeof(valid_stream_param));
invalid_stream_param.stream = NULL; invalid_stream_param.stream = NULL;
err = bt_cap_initiator_unicast_audio_start(&invalid_start_param, unicast_group); err = bt_cap_initiator_unicast_audio_start(&invalid_start_param);
if (err == 0) { if (err == 0) {
FAIL("bt_cap_initiator_unicast_audio_start with NULL stream params stream did not " FAIL("bt_cap_initiator_unicast_audio_start with NULL stream params stream did not "
"fail\n"); "fail\n");
@ -605,7 +597,7 @@ static void unicast_audio_start_inval(struct bt_bap_unicast_group *unicast_group
memcpy(&invalid_stream_param, &valid_stream_param, sizeof(valid_stream_param)); memcpy(&invalid_stream_param, &valid_stream_param, sizeof(valid_stream_param));
invalid_stream_param.ep = NULL; invalid_stream_param.ep = NULL;
err = bt_cap_initiator_unicast_audio_start(&invalid_start_param, unicast_group); err = bt_cap_initiator_unicast_audio_start(&invalid_start_param);
if (err == 0) { if (err == 0) {
FAIL("bt_cap_initiator_unicast_audio_start with NULL stream params ep did not " FAIL("bt_cap_initiator_unicast_audio_start with NULL stream params ep did not "
"fail\n"); "fail\n");
@ -615,7 +607,7 @@ static void unicast_audio_start_inval(struct bt_bap_unicast_group *unicast_group
memcpy(&invalid_stream_param, &valid_stream_param, sizeof(valid_stream_param)); memcpy(&invalid_stream_param, &valid_stream_param, sizeof(valid_stream_param));
invalid_stream_param.codec_cfg = NULL; invalid_stream_param.codec_cfg = NULL;
err = bt_cap_initiator_unicast_audio_start(&invalid_start_param, unicast_group); err = bt_cap_initiator_unicast_audio_start(&invalid_start_param);
if (err == 0) { if (err == 0) {
FAIL("bt_cap_initiator_unicast_audio_start with NULL stream params codec did not " FAIL("bt_cap_initiator_unicast_audio_start with NULL stream params codec did not "
"fail\n"); "fail\n");
@ -627,7 +619,7 @@ static void unicast_audio_start_inval(struct bt_bap_unicast_group *unicast_group
memset(&invalid_codec.meta, 0, sizeof(invalid_codec.meta)); memset(&invalid_codec.meta, 0, sizeof(invalid_codec.meta));
invalid_stream_param.codec_cfg = &invalid_codec; invalid_stream_param.codec_cfg = &invalid_codec;
err = bt_cap_initiator_unicast_audio_start(&invalid_start_param, unicast_group); err = bt_cap_initiator_unicast_audio_start(&invalid_start_param);
if (err == 0) { if (err == 0) {
FAIL("bt_cap_initiator_unicast_audio_start with invalid Codec metadata did not " FAIL("bt_cap_initiator_unicast_audio_start with invalid Codec metadata did not "
"fail\n"); "fail\n");
@ -656,7 +648,7 @@ static void unicast_audio_start(struct bt_bap_unicast_group *unicast_group, bool
UNSET_FLAG(flag_started); UNSET_FLAG(flag_started);
err = bt_cap_initiator_unicast_audio_start(&param, unicast_group); err = bt_cap_initiator_unicast_audio_start(&param);
if (err != 0) { if (err != 0) {
FAIL("Failed to start unicast audio: %d\n", err); FAIL("Failed to start unicast audio: %d\n", err);
return; return;
@ -1129,7 +1121,7 @@ static int cap_initiator_ac_cap_unicast_start(const struct cap_initiator_ac_para
start_param.count = stream_cnt; start_param.count = stream_cnt;
start_param.type = BT_CAP_SET_TYPE_AD_HOC; start_param.type = BT_CAP_SET_TYPE_AD_HOC;
return bt_cap_initiator_unicast_audio_start(&start_param, unicast_group); return bt_cap_initiator_unicast_audio_start(&start_param);
} }
static int cap_initiator_ac_unicast(const struct cap_initiator_ac_param *param, static int cap_initiator_ac_unicast(const struct cap_initiator_ac_param *param,

View file

@ -285,8 +285,7 @@ static void cap_discovery_complete_cb(struct bt_conn *conn, int err,
SET_FLAG(flag_cas_discovered); SET_FLAG(flag_cas_discovered);
} }
static void unicast_start_complete_cb(struct bt_bap_unicast_group *unicast_group, int err, static void unicast_start_complete_cb(int err, struct bt_conn *conn)
struct bt_conn *conn)
{ {
if (err != 0) { if (err != 0) {
FAIL("Failed to start (failing conn %p): %d\n", conn, err); FAIL("Failed to start (failing conn %p): %d\n", conn, err);
@ -308,8 +307,7 @@ static void unicast_update_complete_cb(int err, struct bt_conn *conn)
SET_FLAG(flag_updated); SET_FLAG(flag_updated);
} }
static void unicast_stop_complete_cb(struct bt_bap_unicast_group *unicast_group, int err, static void unicast_stop_complete_cb(int err, struct bt_conn *conn)
struct bt_conn *conn)
{ {
if (err != 0) { if (err != 0) {
FAIL("Failed to stop (failing conn %p): %d\n", conn, err); FAIL("Failed to stop (failing conn %p): %d\n", conn, err);
@ -799,7 +797,7 @@ static int gmap_ac_cap_unicast_start(const struct gmap_unicast_ac_param *param,
start_param.count = stream_cnt; start_param.count = stream_cnt;
start_param.type = BT_CAP_SET_TYPE_AD_HOC; start_param.type = BT_CAP_SET_TYPE_AD_HOC;
return bt_cap_initiator_unicast_audio_start(&start_param, unicast_group); return bt_cap_initiator_unicast_audio_start(&start_param);
} }
static int gmap_ac_unicast(const struct gmap_unicast_ac_param *param, static int gmap_ac_unicast(const struct gmap_unicast_ac_param *param,