Bluetooth: Audio: Shell: Make the default presets non-pointers
Instead of the default presets being pointers, they are changed to allocated structs so that they can be modified. This will allow us to modify the config and metadata in a later patch. Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This commit is contained in:
parent
c8dbb97170
commit
bfe93a3164
|
@ -135,8 +135,8 @@ struct bap_unicast_ac_param {
|
|||
extern struct bt_bap_unicast_group *default_unicast_group;
|
||||
extern struct bt_bap_ep *snks[CONFIG_BT_MAX_CONN][CONFIG_BT_BAP_UNICAST_CLIENT_ASE_SNK_COUNT];
|
||||
extern struct bt_bap_ep *srcs[CONFIG_BT_MAX_CONN][CONFIG_BT_BAP_UNICAST_CLIENT_ASE_SRC_COUNT];
|
||||
extern const struct named_lc3_preset *default_sink_preset;
|
||||
extern const struct named_lc3_preset *default_source_preset;
|
||||
extern struct named_lc3_preset default_sink_preset;
|
||||
extern struct named_lc3_preset default_source_preset;
|
||||
|
||||
int bap_ac_create_unicast_group(const struct bap_unicast_ac_param *param,
|
||||
struct shell_stream *snk_uni_streams[], size_t snk_cnt,
|
||||
|
|
|
@ -133,9 +133,12 @@ static const struct named_lc3_preset lc3_broadcast_presets[] = {
|
|||
};
|
||||
|
||||
/* Default to 16_2_1 */
|
||||
const struct named_lc3_preset *default_sink_preset = &lc3_unicast_presets[3];
|
||||
const struct named_lc3_preset *default_source_preset = &lc3_unicast_presets[3];
|
||||
static const struct named_lc3_preset *default_broadcast_source_preset = &lc3_broadcast_presets[3];
|
||||
struct named_lc3_preset default_sink_preset = {
|
||||
"16_2_1", BT_BAP_LC3_UNICAST_PRESET_16_2_1(LOCATION, CONTEXT)};
|
||||
struct named_lc3_preset default_source_preset = {
|
||||
"16_2_1", BT_BAP_LC3_UNICAST_PRESET_16_2_1(LOCATION, CONTEXT)};
|
||||
static struct named_lc3_preset default_broadcast_source_preset = {
|
||||
"16_2_1", BT_BAP_LC3_BROADCAST_PRESET_16_2_1(LOCATION, CONTEXT)};
|
||||
static bool initialized;
|
||||
|
||||
static struct shell_stream *shell_stream_from_bap_stream(struct bt_bap_stream *bap_stream)
|
||||
|
@ -1035,7 +1038,7 @@ static int cmd_config(const struct shell *sh, size_t argc, char *argv[])
|
|||
dir = BT_AUDIO_DIR_SINK;
|
||||
ep = snks[conn_index][index];
|
||||
|
||||
named_preset = default_sink_preset;
|
||||
named_preset = &default_sink_preset;
|
||||
#endif /* CONFIG_BT_BAP_UNICAST_CLIENT_ASE_SNK_COUNT > 0 */
|
||||
|
||||
#if CONFIG_BT_BAP_UNICAST_CLIENT_ASE_SRC_COUNT > 0
|
||||
|
@ -1043,7 +1046,7 @@ static int cmd_config(const struct shell *sh, size_t argc, char *argv[])
|
|||
dir = BT_AUDIO_DIR_SOURCE;
|
||||
ep = srcs[conn_index][index];
|
||||
|
||||
named_preset = default_source_preset;
|
||||
named_preset = &default_source_preset;
|
||||
#endif /* CONFIG_BT_BAP_UNICAST_CLIENT_ASE_SRC_COUNT > 0 */
|
||||
} else {
|
||||
shell_error(sh, "Unsupported dir: %s", argv[1]);
|
||||
|
@ -1429,15 +1432,15 @@ static int cmd_preset(const struct shell *sh, size_t argc, char *argv[])
|
|||
|
||||
if (!strcmp(argv[1], "sink")) {
|
||||
dir = BT_AUDIO_DIR_SINK;
|
||||
named_preset = default_sink_preset;
|
||||
named_preset = &default_sink_preset;
|
||||
} else if (!strcmp(argv[1], "source")) {
|
||||
dir = BT_AUDIO_DIR_SOURCE;
|
||||
named_preset = default_source_preset;
|
||||
named_preset = &default_source_preset;
|
||||
} else if (!strcmp(argv[1], "broadcast")) {
|
||||
unicast = false;
|
||||
dir = BT_AUDIO_DIR_SOURCE;
|
||||
|
||||
named_preset = default_broadcast_source_preset;
|
||||
named_preset = &default_broadcast_source_preset;
|
||||
} else {
|
||||
shell_error(sh, "Unsupported dir: %s", argv[1]);
|
||||
return -ENOEXEC;
|
||||
|
@ -1451,11 +1454,12 @@ static int cmd_preset(const struct shell *sh, size_t argc, char *argv[])
|
|||
}
|
||||
|
||||
if (!strcmp(argv[1], "sink")) {
|
||||
default_sink_preset = named_preset;
|
||||
memcpy(&default_sink_preset, named_preset, sizeof(default_sink_preset));
|
||||
} else if (!strcmp(argv[1], "source")) {
|
||||
default_source_preset = named_preset;
|
||||
memcpy(&default_source_preset, named_preset, sizeof(default_sink_preset));
|
||||
} else if (!strcmp(argv[1], "broadcast")) {
|
||||
default_broadcast_source_preset = named_preset;
|
||||
memcpy(&default_broadcast_source_preset, named_preset,
|
||||
sizeof(default_sink_preset));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2024,7 +2028,7 @@ static int cmd_create_broadcast(const struct shell *sh, size_t argc,
|
|||
return -ENOEXEC;
|
||||
}
|
||||
|
||||
named_preset = default_broadcast_source_preset;
|
||||
named_preset = &default_broadcast_source_preset;
|
||||
|
||||
for (size_t i = 1U; i < argc; i++) {
|
||||
char *arg = argv[i];
|
||||
|
|
|
@ -242,7 +242,7 @@ static int cmd_cap_initiator_unicast_start(const struct shell *sh, size_t argc,
|
|||
stream_param[start_param.count].member.member = conn;
|
||||
stream_param[start_param.count].stream = stream;
|
||||
stream_param[start_param.count].ep = snk_ep;
|
||||
copy_unicast_stream_preset(uni_stream, default_sink_preset);
|
||||
copy_unicast_stream_preset(uni_stream, &default_sink_preset);
|
||||
stream_param[start_param.count].codec_cfg = &uni_stream->codec_cfg;
|
||||
|
||||
group_stream_params[start_param.count].stream =
|
||||
|
@ -273,7 +273,7 @@ static int cmd_cap_initiator_unicast_start(const struct shell *sh, size_t argc,
|
|||
stream_param[start_param.count].member.member = conn;
|
||||
stream_param[start_param.count].stream = stream;
|
||||
stream_param[start_param.count].ep = src_ep;
|
||||
copy_unicast_stream_preset(uni_stream, default_source_preset);
|
||||
copy_unicast_stream_preset(uni_stream, &default_source_preset);
|
||||
stream_param[start_param.count].codec_cfg = &uni_stream->codec_cfg;
|
||||
group_stream_params[start_param.count].stream =
|
||||
&stream_param[start_param.count].stream->bap_stream;
|
||||
|
@ -368,9 +368,9 @@ static int cmd_cap_initiator_unicast_update(const struct shell *sh, size_t argc,
|
|||
stream_params[param.count].stream = stream;
|
||||
|
||||
if (ep_info.dir == BT_AUDIO_DIR_SINK) {
|
||||
copy_unicast_stream_preset(uni_stream, default_sink_preset);
|
||||
copy_unicast_stream_preset(uni_stream, &default_sink_preset);
|
||||
} else {
|
||||
copy_unicast_stream_preset(uni_stream, default_source_preset);
|
||||
copy_unicast_stream_preset(uni_stream, &default_source_preset);
|
||||
}
|
||||
|
||||
stream_params[param.count].meta = uni_stream->codec_cfg.meta;
|
||||
|
@ -410,9 +410,9 @@ static int cmd_cap_initiator_unicast_update(const struct shell *sh, size_t argc,
|
|||
stream_params[param.count].stream = stream;
|
||||
|
||||
if (ep_info.dir == BT_AUDIO_DIR_SINK) {
|
||||
copy_unicast_stream_preset(uni_stream, default_sink_preset);
|
||||
copy_unicast_stream_preset(uni_stream, &default_sink_preset);
|
||||
} else {
|
||||
copy_unicast_stream_preset(uni_stream, default_source_preset);
|
||||
copy_unicast_stream_preset(uni_stream, &default_source_preset);
|
||||
}
|
||||
|
||||
stream_params[param.count].meta = uni_stream->codec_cfg.meta;
|
||||
|
|
Loading…
Reference in a new issue