Skip to content

Commit 00e83cb

Browse files
alexsvenkoffes
authored andcommitted
applications: nrf5340_audio: Split pref_sample_rate for sink and source
- Enable users to choose preferred sample rate for sink and source - OCT-3467 Signed-off-by: Alexander Svensen <[email protected]>
1 parent c4fafa4 commit 00e83cb

File tree

4 files changed

+58
-25
lines changed

4 files changed

+58
-25
lines changed

applications/nrf5340_audio/broadcast_source/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ int main(void)
594594
ERR_CHK_MSG(ret, "Failed to enable broadcaster(s)");
595595

596596
ret = audio_system_config_set(
597-
bt_audio_codec_cfg_freq_to_freq_hz(CONFIG_BT_AUDIO_PREF_SAMPLE_RATE_VALUE),
597+
bt_audio_codec_cfg_freq_to_freq_hz(CONFIG_BT_AUDIO_PREF_SINK_SAMPLE_RATE_VALUE),
598598
CONFIG_BT_AUDIO_BITRATE_BROADCAST_SRC, VALUE_NOT_SET);
599599
ERR_CHK_MSG(ret, "Failed to set sample- and bitrate");
600600

applications/nrf5340_audio/src/bluetooth/Kconfig

Lines changed: 54 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -43,41 +43,74 @@ config BT_AUDIO_CONCURRENT_TX_STREAMS_MAX
4343
The maximum number of concurrent streams supported in the TX direction.
4444
This is the maximum number of streams that can be active at the same time.
4545

46-
config BT_AUDIO_PREF_SAMPLE_RATE_VALUE
46+
config BT_AUDIO_PREF_SINK_SAMPLE_RATE_VALUE
4747
hex
48-
default 0x03 if BT_AUDIO_PREF_SAMPLE_RATE_16KHZ
49-
default 0x05 if BT_AUDIO_PREF_SAMPLE_RATE_24KHZ
50-
default 0x08 if BT_AUDIO_PREF_SAMPLE_RATE_48KHZ
51-
52-
choice BT_AUDIO_PREF_SAMPLE_RATE
53-
prompt "Preferred BT audio sample rate"
54-
default BT_AUDIO_PREF_SAMPLE_RATE_16KHZ if BT_BAP_BROADCAST_16_2_1
55-
default BT_AUDIO_PREF_SAMPLE_RATE_16KHZ if BT_BAP_BROADCAST_16_2_2
56-
default BT_AUDIO_PREF_SAMPLE_RATE_16KHZ if BT_BAP_UNICAST_16_2_1
57-
default BT_AUDIO_PREF_SAMPLE_RATE_24KHZ if STREAM_BIDIRECTIONAL
58-
default BT_AUDIO_PREF_SAMPLE_RATE_24KHZ if BT_BAP_BROADCAST_24_2_1
59-
default BT_AUDIO_PREF_SAMPLE_RATE_24KHZ if BT_BAP_BROADCAST_24_2_2
60-
default BT_AUDIO_PREF_SAMPLE_RATE_24KHZ if BT_BAP_UNICAST_24_2_1
61-
default BT_AUDIO_PREF_SAMPLE_RATE_48KHZ
48+
default 0x03 if BT_AUDIO_PREF_SINK_SAMPLE_RATE_16KHZ
49+
default 0x05 if BT_AUDIO_PREF_SINK_SAMPLE_RATE_24KHZ
50+
default 0x08 if BT_AUDIO_PREF_SINK_SAMPLE_RATE_48KHZ
51+
52+
choice BT_AUDIO_PREF_SINK_SAMPLE_RATE
53+
prompt "Preferred BT audio sink sample rate"
54+
default BT_AUDIO_PREF_SINK_SAMPLE_RATE_16KHZ if BT_BAP_BROADCAST_16_2_1
55+
default BT_AUDIO_PREF_SINK_SAMPLE_RATE_16KHZ if BT_BAP_BROADCAST_16_2_2
56+
default BT_AUDIO_PREF_SINK_SAMPLE_RATE_16KHZ if BT_BAP_UNICAST_16_2_1
57+
default BT_AUDIO_PREF_SINK_SAMPLE_RATE_24KHZ if STREAM_BIDIRECTIONAL
58+
default BT_AUDIO_PREF_SINK_SAMPLE_RATE_24KHZ if BT_BAP_BROADCAST_24_2_1
59+
default BT_AUDIO_PREF_SINK_SAMPLE_RATE_24KHZ if BT_BAP_BROADCAST_24_2_2
60+
default BT_AUDIO_PREF_SINK_SAMPLE_RATE_24KHZ if BT_BAP_UNICAST_24_2_1
61+
default BT_AUDIO_PREF_SINK_SAMPLE_RATE_48KHZ
6262
help
6363
Select the preferred sample rate to stream if there are more than one to choose from.
6464
Only valid when used by unicast_client if CONFIG_SAMPLE_RATE_CONVERTER=y and
6565
CONFIG_AUDIO_SAMPLE_RATE_48000_HZ=y, meaning 16, 24, and 48kHz are supported.
6666

67-
config BT_AUDIO_PREF_SAMPLE_RATE_48KHZ
67+
config BT_AUDIO_PREF_SINK_SAMPLE_RATE_48KHZ
6868
bool "48 kHz"
6969
help
70-
Select 48000 Hz as the preferred sample rate.
70+
Select 48000 Hz as the preferred sink sample rate.
7171

72-
config BT_AUDIO_PREF_SAMPLE_RATE_24KHZ
72+
config BT_AUDIO_PREF_SINK_SAMPLE_RATE_24KHZ
7373
bool "24 kHz"
7474
help
75-
Select 24000 Hz as the preferred sample rate.
75+
Select 24000 Hz as the preferred sink sample rate.
7676

77-
config BT_AUDIO_PREF_SAMPLE_RATE_16KHZ
77+
config BT_AUDIO_PREF_SINK_SAMPLE_RATE_16KHZ
7878
bool "16 kHz"
7979
help
80-
Select 16000 Hz as the preferred sample rate.
80+
Select 16000 Hz as the preferred sink sample rate.
81+
endchoice
82+
83+
config BT_AUDIO_PREF_SOURCE_SAMPLE_RATE_VALUE
84+
hex
85+
default 0x03 if BT_AUDIO_PREF_SOURCE_SAMPLE_RATE_16KHZ
86+
default 0x05 if BT_AUDIO_PREF_SOURCE_SAMPLE_RATE_24KHZ
87+
default 0x08 if BT_AUDIO_PREF_SOURCE_SAMPLE_RATE_48KHZ
88+
89+
choice BT_AUDIO_PREF_SOURCE_SAMPLE_RATE
90+
prompt "Preferred BT audio source sample rate"
91+
default BT_AUDIO_PREF_SOURCE_SAMPLE_RATE_16KHZ if BT_BAP_UNICAST_16_2_1
92+
default BT_AUDIO_PREF_SOURCE_SAMPLE_RATE_24KHZ if STREAM_BIDIRECTIONAL
93+
default BT_AUDIO_PREF_SOURCE_SAMPLE_RATE_24KHZ if BT_BAP_UNICAST_24_2_1
94+
default BT_AUDIO_PREF_SOURCE_SAMPLE_RATE_48KHZ
95+
help
96+
Select the preferred sample rate to stream if there are more than one to choose from.
97+
Only valid when used by unicast_client if CONFIG_SAMPLE_RATE_CONVERTER=y and
98+
CONFIG_AUDIO_SAMPLE_RATE_48000_HZ=y, meaning 16, 24, and 48kHz are supported.
99+
100+
config BT_AUDIO_PREF_SOURCE_SAMPLE_RATE_48KHZ
101+
bool "48 kHz"
102+
help
103+
Select 48000 Hz as the preferred source sample rate.
104+
105+
config BT_AUDIO_PREF_SOURCE_SAMPLE_RATE_24KHZ
106+
bool "24 kHz"
107+
help
108+
Select 24000 Hz as the preferred source sample rate.
109+
110+
config BT_AUDIO_PREF_SOURCE_SAMPLE_RATE_16KHZ
111+
bool "16 kHz"
112+
help
113+
Select 16000 Hz as the preferred source sample rate.
81114
endchoice
82115

83116
#----------------------------------------------------------------------------#

applications/nrf5340_audio/src/bluetooth/bt_stream/le_audio.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
* using location, stream context, and bitrate parameters.
4747
*/
4848
#define BT_BAP_LC3_PRESET_CONFIGURABLE(_loc, _stream_context, _bitrate) \
49-
BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG(CONFIG_BT_AUDIO_PREF_SAMPLE_RATE_VALUE, \
49+
BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG(CONFIG_BT_AUDIO_PREF_SINK_SAMPLE_RATE_VALUE, \
5050
BT_AUDIO_CODEC_CFG_DURATION_10, _loc, \
5151
LE_AUDIO_SDU_SIZE_OCTETS(_bitrate), 1, \
5252
_stream_context), \

applications/nrf5340_audio/src/bluetooth/bt_stream/unicast/unicast_client.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ static bool sink_parse_cb(struct bt_data *data, void *user_data)
444444
supported_sample_rates_print(lc3_freq_bit, BT_AUDIO_DIR_SINK);
445445

446446
/* Try with the preferred sample rate first */
447-
switch (CONFIG_BT_AUDIO_PREF_SAMPLE_RATE_VALUE) {
447+
switch (CONFIG_BT_AUDIO_PREF_SINK_SAMPLE_RATE_VALUE) {
448448
case BT_AUDIO_CODEC_CFG_FREQ_48KHZ:
449449
if (lc3_freq_bit & BT_AUDIO_CODEC_CAP_FREQ_48KHZ) {
450450
if (bt_audio_codec_cfg_get_freq(&lc3_preset_sink.codec_cfg) !=
@@ -622,7 +622,7 @@ static bool source_parse_cb(struct bt_data *data, void *user_data)
622622
supported_sample_rates_print(lc3_freq_bit, BT_AUDIO_DIR_SOURCE);
623623

624624
/* Try with the preferred sample rate first */
625-
switch (CONFIG_BT_AUDIO_PREF_SAMPLE_RATE_VALUE) {
625+
switch (CONFIG_BT_AUDIO_PREF_SOURCE_SAMPLE_RATE_VALUE) {
626626
case BT_AUDIO_CODEC_CFG_FREQ_48KHZ:
627627
if (lc3_freq_bit & BT_AUDIO_CODEC_CAP_FREQ_48KHZ) {
628628
lc3_preset_source = lc3_preset_source_48_4_1;

0 commit comments

Comments
 (0)