Skip to content

Commit

Permalink
Bluetooth: Audio: Make codec_cap const
Browse files Browse the repository at this point in the history
There is no reason why the capabilities
should be modified by the stack after registration,
nor any reason why a the unicast client application
needs to modify the reported remote capabilities, so
all have been marked as const.

Signed-off-by: Emil Gydesen <[email protected]>
  • Loading branch information
Thalley committed Jun 27, 2023
1 parent 6a4c9be commit 106438a
Show file tree
Hide file tree
Showing 12 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion include/zephyr/bluetooth/audio/pacs.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ extern "C" {
/** @brief Published Audio Capability structure. */
struct bt_pacs_cap {
/** Codec capability reference */
struct bt_audio_codec_cap *codec_cap;
const struct bt_audio_codec_cap *codec_cap;

/* Internally used list node */
sys_snode_t _node;
Expand Down
2 changes: 1 addition & 1 deletion samples/bluetooth/broadcast_audio_sink/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ static struct bt_bap_stream *streams_p[ARRAY_SIZE(streams)];
static struct bt_conn *broadcast_assistant_conn;
static struct bt_le_ext_adv *ext_adv;

static struct bt_audio_codec_cap codec_cap = BT_AUDIO_CODEC_CAP_LC3(
static const struct bt_audio_codec_cap codec_cap = BT_AUDIO_CODEC_CAP_LC3(
0x0000, 0x0000, BT_AUDIO_CODEC_LC3_FREQ_16KHZ | BT_AUDIO_CODEC_LC3_FREQ_24KHZ,
BT_AUDIO_CODEC_LC3_DURATION_10, BT_AUDIO_CODEC_LC3_CHAN_COUNT_SUPPORT(1), 40u, 60u, 1u,
(BT_AUDIO_CONTEXT_TYPE_CONVERSATIONAL | BT_AUDIO_CONTEXT_TYPE_MEDIA));
Expand Down
2 changes: 1 addition & 1 deletion samples/bluetooth/hap_ha/src/bap_unicast_sr.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ NET_BUF_POOL_FIXED_DEFINE(tx_pool, CONFIG_BT_ASCS_ASE_SRC_COUNT,
BT_ISO_SDU_BUF_SIZE(CONFIG_BT_ISO_TX_MTU),
CONFIG_BT_CONN_TX_USER_DATA_SIZE, NULL);

static struct bt_audio_codec_cap lc3_codec_cap = BT_AUDIO_CODEC_CAP_LC3(
static const struct bt_audio_codec_cap lc3_codec_cap = BT_AUDIO_CODEC_CAP_LC3(
0x0000, 0x0000, BT_AUDIO_CODEC_LC3_FREQ_16KHZ | BT_AUDIO_CODEC_LC3_FREQ_24KHZ,
BT_AUDIO_CODEC_LC3_DURATION_10, BT_AUDIO_CODEC_LC3_CHAN_COUNT_SUPPORT(1), 40u, 60u, 1u,
(BT_AUDIO_CONTEXT_TYPE_CONVERSATIONAL | BT_AUDIO_CONTEXT_TYPE_MEDIA));
Expand Down
2 changes: 1 addition & 1 deletion samples/bluetooth/unicast_audio_server/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ NET_BUF_POOL_FIXED_DEFINE(tx_pool, CONFIG_BT_ASCS_ASE_SRC_COUNT,
BT_ISO_SDU_BUF_SIZE(CONFIG_BT_ISO_TX_MTU),
CONFIG_BT_CONN_TX_USER_DATA_SIZE, NULL);

static struct bt_audio_codec_cap lc3_codec_cap = BT_AUDIO_CODEC_CAP_LC3(
static const struct bt_audio_codec_cap lc3_codec_cap = BT_AUDIO_CODEC_CAP_LC3(
0x0000, 0x0000, BT_AUDIO_CODEC_LC3_FREQ_ANY, BT_AUDIO_CODEC_LC3_DURATION_10,
BT_AUDIO_CODEC_LC3_CHAN_COUNT_SUPPORT(1), 40u, 120u, 1u,
(BT_AUDIO_CONTEXT_TYPE_CONVERSATIONAL | BT_AUDIO_CONTEXT_TYPE_MEDIA));
Expand Down
2 changes: 1 addition & 1 deletion subsys/bluetooth/audio/ascs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1231,7 +1231,7 @@ struct codec_cap_lookup_id_data {
uint8_t id;
uint16_t cid;
uint16_t vid;
struct bt_audio_codec_cap *codec_cap;
const struct bt_audio_codec_cap *codec_cap;
};

static bool codec_lookup_id(const struct bt_pacs_cap *cap, void *user_data)
Expand Down
2 changes: 1 addition & 1 deletion subsys/bluetooth/audio/bap_broadcast_sink.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ static struct bt_le_scan_cb broadcast_scan_cb;

struct codec_cap_lookup_id_data {
uint8_t id;
struct bt_audio_codec_cap *codec_cap;
const struct bt_audio_codec_cap *codec_cap;
};

static sys_slist_t sink_cbs = SYS_SLIST_STATIC_INIT(&sink_cbs);
Expand Down
2 changes: 1 addition & 1 deletion subsys/bluetooth/audio/pacs.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ struct pac_records_build_data {
static bool build_pac_records(const struct bt_pacs_cap *cap, void *user_data)
{
struct pac_records_build_data *data = user_data;
struct bt_audio_codec_cap *codec_cap = cap->codec_cap;
const struct bt_audio_codec_cap *codec_cap = cap->codec_cap;
struct net_buf_simple *buf = data->buf;
struct net_buf_simple_state state;
struct bt_pac_codec *pac_codec;
Expand Down
2 changes: 1 addition & 1 deletion subsys/bluetooth/audio/shell/bap.c
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ static int lc3_release(struct bt_bap_stream *stream, struct bt_bap_ascs_rsp *rsp
return 0;
}

static struct bt_audio_codec_cap lc3_codec_cap = BT_AUDIO_CODEC_CAP_LC3(
static const struct bt_audio_codec_cap lc3_codec_cap = BT_AUDIO_CODEC_CAP_LC3(
0x0000, 0x0000, BT_AUDIO_CODEC_LC3_FREQ_ANY, BT_AUDIO_CODEC_LC3_DURATION_ANY,
BT_AUDIO_CODEC_LC3_CHAN_COUNT_SUPPORT(1, 2), 30, 240, 2,
(BT_AUDIO_CONTEXT_TYPE_CONVERSATIONAL | BT_AUDIO_CONTEXT_TYPE_MEDIA));
Expand Down
2 changes: 1 addition & 1 deletion tests/bluetooth/tester/src/btp_bap.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME, CONFIG_BTTESTER_LOG_LEVEL);
#define AVAILABLE_SINK_CONTEXT SUPPORTED_SINK_CONTEXT
#define AVAILABLE_SOURCE_CONTEXT SUPPORTED_SOURCE_CONTEXT

static struct bt_audio_codec_cap default_codec_cap = BT_AUDIO_CODEC_CAP_LC3(
static const struct bt_audio_codec_cap default_codec_cap = BT_AUDIO_CODEC_CAP_LC3(
0x0000, 0x0000, BT_AUDIO_CODEC_LC3_FREQ_ANY, BT_AUDIO_CODEC_LC3_DURATION_10,
BT_AUDIO_CODEC_LC3_CHAN_COUNT_SUPPORT(1), 40u, 120u, 1u,
(BT_AUDIO_CONTEXT_TYPE_CONVERSATIONAL | BT_AUDIO_CONTEXT_TYPE_MEDIA));
Expand Down
2 changes: 1 addition & 1 deletion tests/bsim/bluetooth/audio/src/bap_broadcast_sink_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ static struct bt_bap_broadcast_sink *g_sink;
static struct bt_bap_stream broadcast_sink_streams[CONFIG_BT_BAP_BROADCAST_SNK_STREAM_COUNT];
static struct bt_bap_stream *streams[ARRAY_SIZE(broadcast_sink_streams)];

static struct bt_audio_codec_cap codec_cap_16_2_1 = BT_AUDIO_CODEC_CAP_LC3(
static const struct bt_audio_codec_cap codec_cap_16_2_1 = BT_AUDIO_CODEC_CAP_LC3(
0x0000, 0x0000, BT_AUDIO_CODEC_LC3_FREQ_ANY, BT_AUDIO_CODEC_LC3_DURATION_ANY,
BT_AUDIO_CODEC_LC3_CHAN_COUNT_SUPPORT(1, 2), 30, 240, 2,
(BT_AUDIO_CONTEXT_TYPE_CONVERSATIONAL | BT_AUDIO_CONTEXT_TYPE_MEDIA));
Expand Down
2 changes: 1 addition & 1 deletion tests/bsim/bluetooth/audio/src/bap_unicast_server_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ extern enum bst_result_t bst_result;

#define LONG_META_LEN (sizeof((uint8_t []){LONG_META}) + 1U) /* Size of data + type */

static struct bt_audio_codec_cap lc3_codec_cap = {
static const struct bt_audio_codec_cap lc3_codec_cap = {
.path_id = BT_ISO_DATA_PATH_HCI,
.id = BT_AUDIO_CODEC_LC3_ID,
.cid = 0x0000U,
Expand Down
2 changes: 1 addition & 1 deletion tests/bsim/bluetooth/audio/src/cap_acceptor_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ CREATE_FLAG(flag_pa_sync_lost);
static struct bt_bap_broadcast_sink *g_broadcast_sink;
static struct bt_cap_stream broadcast_sink_streams[CONFIG_BT_BAP_BROADCAST_SNK_STREAM_COUNT];

static struct bt_audio_codec_cap codec_cap_16_2_1 = BT_AUDIO_CODEC_CAP_LC3(
static const struct bt_audio_codec_cap codec_cap_16_2_1 = BT_AUDIO_CODEC_CAP_LC3(
0x0000, 0x0000, BT_AUDIO_CODEC_LC3_FREQ_ANY, BT_AUDIO_CODEC_LC3_DURATION_ANY,
BT_AUDIO_CODEC_LC3_CHAN_COUNT_SUPPORT(1, 2), 30, 240, 2,
(BT_AUDIO_CONTEXT_TYPE_CONVERSATIONAL | BT_AUDIO_CONTEXT_TYPE_MEDIA));
Expand Down

0 comments on commit 106438a

Please sign in to comment.