From 106438a6cb08e5fbc9320fe98e646c0e11f25a0a Mon Sep 17 00:00:00 2001 From: Emil Gydesen Date: Fri, 19 May 2023 16:55:11 +0200 Subject: [PATCH] Bluetooth: Audio: Make codec_cap const 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 --- include/zephyr/bluetooth/audio/pacs.h | 2 +- samples/bluetooth/broadcast_audio_sink/src/main.c | 2 +- samples/bluetooth/hap_ha/src/bap_unicast_sr.c | 2 +- samples/bluetooth/unicast_audio_server/src/main.c | 2 +- subsys/bluetooth/audio/ascs.c | 2 +- subsys/bluetooth/audio/bap_broadcast_sink.c | 2 +- subsys/bluetooth/audio/pacs.c | 2 +- subsys/bluetooth/audio/shell/bap.c | 2 +- tests/bluetooth/tester/src/btp_bap.c | 2 +- tests/bsim/bluetooth/audio/src/bap_broadcast_sink_test.c | 2 +- tests/bsim/bluetooth/audio/src/bap_unicast_server_test.c | 2 +- tests/bsim/bluetooth/audio/src/cap_acceptor_test.c | 2 +- 12 files changed, 12 insertions(+), 12 deletions(-) diff --git a/include/zephyr/bluetooth/audio/pacs.h b/include/zephyr/bluetooth/audio/pacs.h index 3400baac92b96e8..4b9b7e29a2ae033 100644 --- a/include/zephyr/bluetooth/audio/pacs.h +++ b/include/zephyr/bluetooth/audio/pacs.h @@ -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; diff --git a/samples/bluetooth/broadcast_audio_sink/src/main.c b/samples/bluetooth/broadcast_audio_sink/src/main.c index ea1ceb95c85199e..04c2863c3bdc002 100644 --- a/samples/bluetooth/broadcast_audio_sink/src/main.c +++ b/samples/bluetooth/broadcast_audio_sink/src/main.c @@ -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)); diff --git a/samples/bluetooth/hap_ha/src/bap_unicast_sr.c b/samples/bluetooth/hap_ha/src/bap_unicast_sr.c index 7d8e114ad883836..a60980eaf833edc 100644 --- a/samples/bluetooth/hap_ha/src/bap_unicast_sr.c +++ b/samples/bluetooth/hap_ha/src/bap_unicast_sr.c @@ -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)); diff --git a/samples/bluetooth/unicast_audio_server/src/main.c b/samples/bluetooth/unicast_audio_server/src/main.c index 2523be31e0eb109..269a8aa9d1d7a61 100644 --- a/samples/bluetooth/unicast_audio_server/src/main.c +++ b/samples/bluetooth/unicast_audio_server/src/main.c @@ -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)); diff --git a/subsys/bluetooth/audio/ascs.c b/subsys/bluetooth/audio/ascs.c index cfa3dbe0f332cc3..a17c1b0397f75a9 100644 --- a/subsys/bluetooth/audio/ascs.c +++ b/subsys/bluetooth/audio/ascs.c @@ -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) diff --git a/subsys/bluetooth/audio/bap_broadcast_sink.c b/subsys/bluetooth/audio/bap_broadcast_sink.c index 66a45fef555a378..b6bbf30cea20906 100644 --- a/subsys/bluetooth/audio/bap_broadcast_sink.c +++ b/subsys/bluetooth/audio/bap_broadcast_sink.c @@ -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); diff --git a/subsys/bluetooth/audio/pacs.c b/subsys/bluetooth/audio/pacs.c index 5a690253bb2a3d1..449e3543329d15f 100644 --- a/subsys/bluetooth/audio/pacs.c +++ b/subsys/bluetooth/audio/pacs.c @@ -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; diff --git a/subsys/bluetooth/audio/shell/bap.c b/subsys/bluetooth/audio/shell/bap.c index 7e32373ad4712af..a5733274e46f3dd 100644 --- a/subsys/bluetooth/audio/shell/bap.c +++ b/subsys/bluetooth/audio/shell/bap.c @@ -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)); diff --git a/tests/bluetooth/tester/src/btp_bap.c b/tests/bluetooth/tester/src/btp_bap.c index 39fd995fb69a18e..fec9d87483b9e3c 100644 --- a/tests/bluetooth/tester/src/btp_bap.c +++ b/tests/bluetooth/tester/src/btp_bap.c @@ -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)); diff --git a/tests/bsim/bluetooth/audio/src/bap_broadcast_sink_test.c b/tests/bsim/bluetooth/audio/src/bap_broadcast_sink_test.c index fe42c2dc2de36bf..4494502800b2839 100644 --- a/tests/bsim/bluetooth/audio/src/bap_broadcast_sink_test.c +++ b/tests/bsim/bluetooth/audio/src/bap_broadcast_sink_test.c @@ -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)); diff --git a/tests/bsim/bluetooth/audio/src/bap_unicast_server_test.c b/tests/bsim/bluetooth/audio/src/bap_unicast_server_test.c index b4cf159986bc1c0..4f2c9f6ad875f87 100644 --- a/tests/bsim/bluetooth/audio/src/bap_unicast_server_test.c +++ b/tests/bsim/bluetooth/audio/src/bap_unicast_server_test.c @@ -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, diff --git a/tests/bsim/bluetooth/audio/src/cap_acceptor_test.c b/tests/bsim/bluetooth/audio/src/cap_acceptor_test.c index bf5d382391ba8f3..c55b560108c18da 100644 --- a/tests/bsim/bluetooth/audio/src/cap_acceptor_test.c +++ b/tests/bsim/bluetooth/audio/src/cap_acceptor_test.c @@ -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));