Seeking advice on stereo audio transmission from a single headset device

I’m working with the Audio Application (from the Nordic sample program) on an nRF5340 Audio DK as a gateway, and a custom board with an nRF5340 as a headset. The custom headset board has two audio channels, and my goal is to transmit the stereo audio from the single headset to the gateway in the bidirectional mode.

I’ve made modifications to the Audio Application to enable the gateway device to decode two audio channels and the headset device to encode two channels. However, I'm currently facing an issue with the following error message on the headset device: “<err> bt_le_audio_tx: The encoded data size does not match the SDU size”.

My question is: Is it possible to achieve this stereo audio transmission setup by only configuring Kconfig and making minor changes to the code, or do I need to make more substantial modifications?

Any insights or suggestions would be greatly appreciated!

Thanks in advance!

NCS version: 2.6.1

Parents
  • Hi,

    Can you show your modifications to the nrf5340_audio application?

    Can you provide your full application log?

    Best regards,
    Dejan

  • Hi Dejan, thank you for your quick response. Here are the code changes and the log.

    Code modifications:

    // src/audio/audio_system.c
    
    static void audio_gateway_configure(void)
    {
        // ..
        sw_codec_cfg.decoder.num_ch = 2;
        sw_codec_cfg.decoder.channel_mode = SW_CODEC_STEREO;
        // ..
    }
    
    static void audio_headset_configure(void)
    {
        // ..
    	sw_codec_cfg.encoder.num_ch = 2;
    	sw_codec_cfg.encoder.channel_mode = SW_CODEC_STEREO;
    	// ..
    }
     
    // unicast_server/Kconfig.defaults
    config LC3_ENC_CHAN_MAX
    default 2
    
    // unicast_client/Kconfig.defaults
    config LC3_DEC_CHAN_MAX
    default 2
    
    //prj.conf
    CONFIG_STREAM_BIDIRECTIONAL=y
     
    // src/bluetooth/bt_stream/bt_le_audio_tx.c
    int bt_le_audio_tx_send(struct bt_bap_stream **bap_streams, struct le_audio_encoded_audio enc_audio,
    uint8_t streams_to_tx)
    {
        // ...
    	// if ((enc_audio.num_ch == 1) || (enc_audio.num_ch == streams_to_tx)) {
    	// 	data_size_pr_stream = enc_audio.size / enc_audio.num_ch;
    	// } else {
    	// 	LOG_ERR("Num encoded channels must be 1 or equal to num streams");
    	// 	return -EINVAL;
    	// }
        data_size_pr_stream = enc_audio.size; // temporary adjustment
        // ...
    }
    Log: 
    *** Booting nRF Connect SDK v3.5.99-ncs1-1 ***
    -- [00:00:00.911,956] <dbg> main: main: nRF5340 APP core started
    HL [00:00:01.065,979] <inf> fw_info:
    nRF5340 Audio nRF5340 Audio DK cpuapp
    NCS base version: 2.6.1
    Cmake run : Tue Nov 19 10:50:14 2024
    HL [00:00:01.065,979] <inf> fw_info: ------- DEBUG BUILD -------
    HL [00:00:01.065,979] <inf> fw_info: HEADSET left device
    HL [00:00:01.085,266] <inf> bt_mgmt: Clearing all bonds
    HL [00:00:01.085,632] <inf> bt_mgmt_ctlr_cfg: Controller: SoftDevice: Version 5.4 (0x0d), Revision 8591
    HL [00:00:01.085,845] <inf> bt_mgmt: Local identity addr: D9:D6:B4:D9:C1:D1 (random)
    HL [00:00:01.087,463] <dbg> main: ext_adv_populate: Size of adv data: 48, num_elements: 6
    HL [00:00:01.089,996] <inf> bt_mgmt_adv: Local addr: 65:0E:75:D0:2C:B0 (random)
    HL [00:00:01.090,515] <inf> bt_mgmt_adv: Advertising successfully started
    HL [00:00:01.211,242] <inf> bt_mgmt: Connected: 45:DD:13:98:7A:E0 (random)
    HL [00:00:01.211,273] <inf> main: Connected
    HL [00:00:01.933,288] <inf> main: Security changed
    HL [00:00:04.093,139] <inf> bt_content_ctrl_media: Discovery of MCS finished
    HL [00:00:06.092,864] <inf> unicast_server: LC3 codec config for sink:
    HL [00:00:06.092,895] <inf> unicast_server: Frequency: 16000 Hz
    HL [00:00:06.092,895] <inf> unicast_server: Duration: 10000 us
    HL [00:00:06.092,895] <inf> unicast_server: Channel allocation: 0x1
    HL [00:00:06.092,895] <inf> unicast_server: Octets per frame: 40 (32000 bps)
    HL [00:00:06.092,895] <inf> unicast_server: Frames per SDU: 1
    HL [00:00:06.093,353] <dbg> main: le_audio_msg_sub_thread: Received event = 1, current state = 1
    HL [00:00:06.093,353] <dbg> main: le_audio_msg_sub_thread: LE audio config received
    HL [00:00:06.093,353] <dbg> main: le_audio_msg_sub_thread: Sampling rate: 16000 Hz
    HL [00:00:06.093,383] <dbg> main: le_audio_msg_sub_thread: Bitrate (compressed): 32000 bps
    HL [00:00:06.093,383] <dbg> main: le_audio_msg_sub_thread: Direction: 1
    HL [00:00:06.093,383] <dbg> audio_system: audio_system_config_set: audio_system_config_set Encoder: 0, Decoder: 16000, Bits: 0
    HL [00:00:06.093,414] <dbg> audio_system: audio_system_config_set: audio_system_config_set Decoder sample rate: 0
    HL [00:00:06.094,299] <inf> unicast_server: LC3 codec config for source:
    HL [00:00:06.094,299] <inf> unicast_server: Frequency: 16000 Hz
    HL [00:00:06.094,299] <inf> unicast_server: Duration: 10000 us
    HL [00:00:06.094,329] <inf> unicast_server: Channel allocation: 0x1
    HL [00:00:06.094,329] <inf> unicast_server: Octets per frame: 40 (32000 bps)
    HL [00:00:06.094,329] <inf> unicast_server: Frames per SDU: 1
    HL [00:00:06.094,665] <dbg> main: le_audio_msg_sub_thread: Received event = 1, current state = 1
    HL [00:00:06.094,665] <dbg> main: le_audio_msg_sub_thread: LE audio config received
    HL [00:00:06.094,665] <dbg> main: le_audio_msg_sub_thread: Sampling rate: 16000 Hz
    HL [00:00:06.094,696] <dbg> main: le_audio_msg_sub_thread: Bitrate (compressed): 32000 bps
    HL [00:00:06.094,696] <dbg> main: le_audio_msg_sub_thread: Direction: 2
    HL [00:00:06.094,696] <dbg> audio_system: audio_system_config_set: audio_system_config_set Encoder: 16000, Decoder: 0, Bits: 32000
    HL [00:00:06.094,696] <dbg> audio_system: audio_system_config_set: audio_system_config_set Encoder sample rate: 16000
    HL [00:00:06.173,522] <dbg> main: le_audio_msg_sub_thread: Received event = 2, current state = 1
    HL [00:00:06.173,522] <dbg> main: le_audio_msg_sub_thread: Set presentation delay
    HL [00:00:06.173,553] <inf> main: Presentation delay 10000 us is set by initiator
    HL [00:00:06.173,553] <dbg> main: le_audio_msg_sub_thread: Received event = 2, current state = 1
    HL [00:00:06.173,583] <dbg> main: le_audio_msg_sub_thread: Set presentation delay
    HL [00:00:06.173,583] <inf> main: Presentation delay 10000 us is set by initiator
    HL [00:00:06.499,664] <inf> unicast_server: Stream 0x2000a304 started
    HL [00:00:06.499,847] <dbg> main: le_audio_msg_sub_thread: Received event = 3, current state = 1
    HL [00:00:06.499,847] <dbg> main: le_audio_msg_sub_thread: LE audio evt streaming
    HL [00:00:06.499,877] <dbg> audio_system: audio_system_start: Init codec
    HL [00:00:06.499,877] <dbg> audio_system: audio_system_start: audio_system_start Encoder sample rate: 16000
    HL [00:00:06.499,877] <dbg> sw_codec_select: sw_codec_init: INIT LC3
    HL [00:00:06.504,119] <dbg> sw_codec_select: sw_codec_init: LC3 encoder enabled
    HL [00:00:06.504,150] <dbg> sw_codec_select: sw_codec_init: Encode: 16000Hz 16bits 10000us 32000bps 2 channel(s)
    HL [00:00:06.504,455] <dbg> sw_codec_select: sw_codec_init: LC3 decoder enabled
    HL [00:00:06.504,486] <dbg> sw_codec_select: sw_codec_init: Decode: 16000Hz 16bits 10000us 1 channel(s)
    HL [00:00:06.510,375] <wrn> le_audio_rx: Not in streaming state, throwing data: 1
    HL [00:00:06.520,385] <wrn> le_audio_rx: Not in streaming state, throwing data: 1
    HL [00:00:06.530,364] <wrn> le_audio_rx: Not in streaming state, throwing data: 1
    HL [00:00:06.532,379] <inf> unicast_server: Stream 0x2000a328 started
    HL [00:00:06.540,374] <wrn> le_audio_rx: Not in streaming state, throwing data: 1
    HL [00:00:06.550,384] <wrn> le_audio_rx: Not in streaming state, throwing data: 1
    HL [00:00:06.560,363] <wrn> le_audio_rx: Not in streaming state, throwing data: 1
    HL [00:00:06.570,343] <wrn> le_audio_rx: Not in streaming state, throwing data: 1
    HL [00:00:06.580,383] <wrn> le_audio_rx: Not in streaming state, throwing data: 1
    HL [00:00:06.590,362] <wrn> le_audio_rx: Not in streaming state, throwing data: 1
    HL [00:00:06.600,372] <wrn> le_audio_rx: Not in streaming state, throwing data: 1
    HL [00:00:06.610,351] <wrn> le_audio_rx: Not in streaming state, throwing data: 1
    HL [00:00:06.620,361] <wrn> le_audio_rx: Not in streaming state, throwing data: 1
    HL [00:00:06.630,371] <wrn> le_audio_rx: Not in streaming state, throwing data: 1
    HL [00:00:06.640,350] <wrn> le_audio_rx: Not in streaming state, throwing data: 1
    HL [00:00:06.650,360] <wrn> le_audio_rx: Not in streaming state, throwing data: 1
    HL [00:00:06.660,369] <wrn> le_audio_rx: Not in streaming state, throwing data: 1
    HL [00:00:06.670,349] <wrn> le_audio_rx: Not in streaming state, throwing data: 1
    HL [00:00:06.680,358] <wrn> le_audio_rx: Not in streaming state, throwing data: 1
    HL [00:00:06.680,603] <dbg> main: le_audio_msg_sub_thread: Received event = 3, current state = 0
    HL [00:00:06.680,603] <dbg> main: le_audio_msg_sub_thread: LE audio evt streaming
    HL [00:00:06.680,603] <dbg> audio_system: audio_system_encoder_start: Encoder started
    HL [00:00:06.680,633] <dbg> main: le_audio_msg_sub_thread: Got streaming event in streaming state
    HL [00:00:06.693,481] <err> bt_le_audio_tx: The encoded data size does not match the SDU size
    HL [00:00:06.693,481] <wrn> main: Problem with sending LE audio data, ret: -22
    HL [00:00:06.694,610] <wrn> audio_datapath: Data received, total under-runs: 12
    HL [00:00:06.703,338] <err> bt_le_audio_tx: The encoded data size does not match the SDU size
    HL [00:00:06.713,287] <err> bt_le_audio_tx: The encoded data size does not match the SDU size
    HL [00:00:06.723,297] <err> bt_le_audio_tx: The encoded data size does not match the SDU size
    HL [00:00:06.733,428] <err> bt_le_audio_tx: The encoded data size does not match the SDU size
    HL [00:00:06.743,255] <err> bt_le_audio_tx: The encoded data size does not match the SDU size
    HL [00:00:06.753,417] <err> bt_le_audio_tx: The encoded data size does not match the SDU size
    HL [00:00:06.763,427] <err> bt_le_audio_tx: The encoded data size does not match the SDU size
    HL [00:00:06.773,925] <err> bt_le_audio_tx: The encoded data size does not match the SDU size
  • Hi,

    Thank you for providing additional information.

    We are looking into this issue internally and I hope that we will be able to provide the resolution soon. Please note that we might need more time than usual. Currently I am not able to provide exact estimate on when the issue might get resolved. I will provide status update by the end of next week.

    Thank you for your patience.

    Best regards,
    Dejan

  • Ok, thank you! I look forward to hearing the update.

  • Hi,

    I have discussed the issue with our developers. Here is the demo branch
    https://github.com/rick1082/sdk-nrf/commits/cis_stereo_audio_sink_pre280
    Please let me know if you have any further questions.

    Best regards,
    Dejan

  • Hi Dejan, thank you for the quick update.

    I’m not quite sure how to apply the modification to my code, as the base code differs from what you’ve provided.

    I got the Audio Application project through the VS Code extension, nRF Connect. Specifically, I selected “Create a new application” > “Copy a sample” > “nRF5340 Audio application”. The toolchains and west workspace are v2.6.1.

    Most of the lines of the code referenced in the commit do not exist in my codebase..

    I also tried downloading the whole sdk-nrf/applications/nrf5340_audio directory in the cis_stereo_audio_sink_pre280 branch and compiling it, but ran into Kconfig warnings that prevented the build from succeeding.

    Is the version I’m using no longer actively supported, or could you provide advice based on the code in that version?

Reply
  • Hi Dejan, thank you for the quick update.

    I’m not quite sure how to apply the modification to my code, as the base code differs from what you’ve provided.

    I got the Audio Application project through the VS Code extension, nRF Connect. Specifically, I selected “Create a new application” > “Copy a sample” > “nRF5340 Audio application”. The toolchains and west workspace are v2.6.1.

    Most of the lines of the code referenced in the commit do not exist in my codebase..

    I also tried downloading the whole sdk-nrf/applications/nrf5340_audio directory in the cis_stereo_audio_sink_pre280 branch and compiling it, but ran into Kconfig warnings that prevented the build from succeeding.

    Is the version I’m using no longer actively supported, or could you provide advice based on the code in that version?

Children
Related