Getting bad frames when adding advertising in the broadcast_sink of the nRF5340 audio application.

Hi,

I am trying to implement the scan delegator in the broadcast_sink of the nRF5340 audio application.

Currently, I am adding the advertising feature in the broadcast_sink, but the audio quality deteriorates.

Here is the code I added in broadcast_sink/main.c.

static const struct bt_data ad[] = {
	BT_DATA_BYTES(BT_DATA_FLAGS, (BT_LE_AD_GENERAL | BT_LE_AD_NO_BREDR)),
};

int main(void)
{
	int ret;

	LOG_DBG("Main started");

	ret = nrf5340_audio_dk_init();
	ERR_CHK(ret);

	ret = fw_info_app_print();
	ERR_CHK(ret);

	ret = bt_mgmt_init();
	ERR_CHK(ret);

	ret = audio_system_init();
	ERR_CHK(ret);

	ret = zbus_subscribers_create();
	ERR_CHK_MSG(ret, "Failed to create zbus subscriber threads");

	ret = zbus_link_producers_observers();
	ERR_CHK_MSG(ret, "Failed to link zbus producers and observers");

	ret = le_audio_rx_init();
	ERR_CHK_MSG(ret, "Failed to initialize rx path");

	ret = broadcast_sink_enable(le_audio_rx_data_handler);
	ERR_CHK_MSG(ret, "Failed to enable broadcast sink");

	ret = bt_mgmt_adv_start(0, ad, ARRAY_SIZE(ad), NULL, 0, true);
	ERR_CHK_MSG(ret, "Failed to advertising");

	ret = bt_mgmt_scan_start(0, 0, BT_MGMT_SCAN_TYPE_BROADCAST, CONFIG_BT_AUDIO_BROADCAST_NAME,
				 BRDCAST_ID_NOT_USED);
	ERR_CHK_MSG(ret, "Failed to start scanning");

	return 0;
}

I also enabled the LE_AUDIO_RX_LOG_LEVEL_DBG.

After building and flashing into the audio DK, I found that the audio quality worsened. The logs indicate that the bad frame count is increasing.

Below is my console log:

 *** Booting nRF Connect SDK v2.7.0-5cb85570ca43 ***
*** Using Zephyr OS v3.6.99-ded7e9fcce1e ***
HL [00:00:00.268,463] <inf> board_version: Compatible board/HW version found: 1.0.0
HL [00:00:00.293,457] <inf> fw_info:
         nRF5340 Audio nRF5340 Audio DK cpuapp
         NCS base version: 2.7.0
         Cmake run : Mon Jul 08 23:45:43 2024
HL [00:00:00.293,487] <inf> fw_info: ------- DEBUG BUILD -------
HL [00:00:00.293,487] <inf> fw_info: HEADSET left device
HL [00:00:00.349,975] <inf> bt_mgmt_ctlr_cfg: Controller: SoftDevice: Version 5.4 (0x0d), Revision 8699
HL [00:00:00.350,067] <inf> bt_mgmt: Local identity addr: FE:0F:1E:D2:49:D9 (random)
HL [00:00:00.380,187] <inf> bt_mgmt_adv: Local addr: FE:0F:1E:D2:49:D9 (random)
HL [00:00:00.380,889] <inf> bt_mgmt_adv: Advertising successfully started
uart:~$ HL [00:00:00.381,713] <inf> bt_mgmt_scan: Local addr: FE:0F:1E:D2:49:D9 (random). May time out. Updates not printed
HL [00:00:00.381,713] <inf> bt_mgmt_scan: Scanning successfully started
HL [00:00:00.381,713] <inf> bt_mgmt_scan: Local addr: FE:0F:1E:D2:49:D9 (random). May time out. Updates not printed
HL [00:00:00.381,713] <inf> bt_mgmt_scan: Scanning successfully started
uart:~$ HL [00:00:00.687,316] <inf> bt_mgmt_scan: PA synced to name: NRF5340_BROADCASTER, id: 0x97a148, addr: 30:27:95:33:93:AE (random)
HL [00:00:00.687,316] <inf> bt_mgmt_scan: PA synced to name: NRF5340_BROADCASTER, id: 0x97a148, addr: 30:27:95:33:93:AE (random)
uart:~$ HL [00:00:00.688,293] <inf> broadcast_sink: Syncing to broadcast stream index 0
HL [00:00:00.688,476] <inf> main: Presentation delay 3000 us is set
HL [00:00:01.290,344] <inf> broadcast_sink: Stream index 0 started
HL [00:00:01.290,344] <inf> broadcast_sink: Codec config for LC3:
HL [00:00:01.290,374] <inf> broadcast_sink:     Frequency: 48000 Hz
HL [00:00:01.290,374] <inf> broadcast_sink:     Frame Duration: 10000 us
HL [00:00:01.290,374] <inf> broadcast_sink:     Octets per frame: 80 (64000 kbps)
HL [00:00:01.290,374] <inf> broadcast_sink:     Frames per SDU: 1
HL [00:00:01.290,374] <inf> broadcast_sink:     Channel allocation: 0x1
HL [00:00:01.291,015] <wrn> le_audio_rx: Not in streaming state (1), thrown 1 packet(s)
HL [00:00:01.310,363] <inf> audio_datapath: Drft comp state: CALIB
HL [00:00:01.312,347] <wrn> audio_datapath: Data received, total under-runs: 10
HL [00:00:01.342,346] <wrn> audio_datapath: Data received, total under-runs: 20
HL [00:00:01.410,369] <inf> audio_datapath: Drft comp state: OFFSET
HL [00:00:00.688,293] <inf> broadcast_sink: Syncing to broadcast stream index 0
HL [00:00:00.688,476] <inf> main: Presentation delay 3000 us is set
HL [00:00:01.290,344] <inf> broadcast_sink: Stream index 0 started
HL [00:00:01.290,344] <inf> broadcast_sink: Codec config for LC3:
HL [00:00:01.290,374] <inf> broadcast_sink:     Frequency: 48000 Hz
HL [00:00:01.290,374] <inf> broadcast_sink:     Frame Duration: 10000 us
HL [00:00:01.290,374] <inf> broadcast_sink:     Octets per frame: 80 (64000 kbps)
HL [00:00:01.290,374] <inf> broadcast_sink:     Frames per SDU: 1
HL [00:00:01.290,374] <inf> broadcast_sink:     Channel allocation: 0x1
HL [00:00:01.291,015] <wrn> le_audio_rx: Not in streaming state (1), thrown 1 packet(s)
HL [00:00:01.310,363] <inf> audio_datapath: Drft comp state: CALIB
HL [00:00:01.312,347] <wrn> audio_datapath: Data received, total under-runs: 10
HL [00:00:01.342,346] <wrn> audio_datapath: Data received, total under-runs: 20
HL [00:00:01.410,369] <inf> audio_datapath: Drft comp state: OFFSET
uart:~$ HL [00:00:01.810,180] <inf> audio_datapath: Drft comp state: LOCKED
HL [00:00:01.820,098] <inf> audio_datapath: Pres comp state: MEAS
HL [00:00:01.930,603] <inf> audio_datapath: Pres comp state: WAIT
HL [00:00:02.032,165] <wrn> audio_datapath: Data received, total under-runs: 24
HL [00:00:02.070,098] <inf> audio_datapath: Pres comp state: INIT
HL [00:00:02.080,108] <inf> audio_datapath: Pres comp state: MEAS
HL [00:00:02.190,185] <inf> audio_datapath: Pres comp state: WAIT
HL [00:00:02.212,158] <wrn> audio_datapath: Data received, total under-runs: 28
HL [00:00:02.280,242] <dbg> le_audio_rx: le_audio_rx_data_handler: ISO RX SDUs: Ch: 0 Total: 100 Bad: 10 Size mismatch 10
HL [00:00:02.330,200] <inf> audio_datapath: Pres comp state: INIT
HL [00:00:02.350,311] <inf> audio_datapath: Pres comp state: MEAS
HL [00:00:01.810,180] <inf> audio_datapath: Drft comp state: LOCKED
HL [00:00:01.820,098] <inf> audio_datapath: Pres comp state: MEAS
HL [00:00:01.930,603] <inf> audio_datapath: Pres comp state: WAIT
HL [00:00:02.032,165] <wrn> audio_datapath: Data received, total under-runs: 24
HL [00:00:02.070,098] <inf> audio_datapath: Pres comp state: INIT
HL [00:00:02.080,108] <inf> audio_datapath: Pres comp state: MEAS
HL [00:00:02.190,185] <inf> audio_datapath: Pres comp state: WAIT
HL [00:00:02.212,158] <wrn> audio_datapath: Data received, total under-runs: 28
HL [00:00:02.280,242] <dbg> le_audio_rx: le_audio_rx_data_handler: ISO RX SDUs: Ch: 0 Total: 100 Bad: 10 Size mismatch 10
HL [00:00:02.330,200] <inf> audio_datapath: Pres comp state: INIT
HL [00:00:02.350,311] <inf> audio_datapath: Pres comp state: MEAS
uart:~$ HL [00:00:02.451,385] <inf> audio_datapath: Pres comp state: WAIT
HL [00:00:02.522,155] <wrn> audio_datapath: Data received, total under-runs: 32
HL [00:00:02.591,369] <inf> audio_datapath: Pres comp state: INIT
HL [00:00:02.600,128] <inf> audio_datapath: Pres comp state: MEAS
HL [00:00:02.710,113] <inf> audio_datapath: Pres comp state: WAIT
HL [00:00:02.842,163] <wrn> audio_datapath: Data received, total under-runs: 36
HL [00:00:02.850,219] <inf> audio_datapath: Pres comp state: INIT
HL [00:00:02.870,330] <inf> audio_datapath: Pres comp state: MEAS
HL [00:00:02.970,123] <inf> audio_datapath: Pres comp state: WAIT
HL [00:00:03.062,164] <wrn> audio_datapath: Data received, total under-runs: 39
HL [00:00:03.110,198] <inf> audio_datapath: Pres comp state: INIT
HL [00:00:03.130,310] <inf> audio_datapath: Pres comp state: MEAS
HL [00:00:02.451,385] <inf> audio_datapath: Pres comp state: WAIT
HL [00:00:02.522,155] <wrn> audio_datapath: Data received, total under-runs: 32
HL [00:00:02.591,369] <inf> audio_datapath: Pres comp state: INIT
HL [00:00:02.600,128] <inf> audio_datapath: Pres comp state: MEAS
HL [00:00:02.710,113] <inf> audio_datapath: Pres comp state: WAIT
HL [00:00:02.842,163] <wrn> audio_datapath: Data received, total under-runs: 36
HL [00:00:02.850,219] <inf> audio_datapath: Pres comp state: INIT
HL [00:00:02.870,330] <inf> audio_datapath: Pres comp state: MEAS
HL [00:00:02.970,123] <inf> audio_datapath: Pres comp state: WAIT
HL [00:00:03.062,164] <wrn> audio_datapath: Data received, total under-runs: 39
HL [00:00:03.110,198] <inf> audio_datapath: Pres comp state: INIT
HL [00:00:03.130,310] <inf> audio_datapath: Pres comp state: MEAS
uart:~$ HL [00:00:03.230,133] <inf> audio_datapath: Pres comp state: WAIT
HL [00:00:03.280,120] <dbg> le_audio_rx: le_audio_rx_data_handler: ISO RX SDUs: Ch: 0 Total: 200 Bad: 21 Size mismatch 21
HL [00:00:03.302,185] <wrn> audio_datapath: Data received, total under-runs: 43
HL [00:00:03.371,276] <inf> audio_datapath: Pres comp state: INIT
HL [00:00:03.380,126] <inf> audio_datapath: Pres comp state: MEAS
HL [00:00:03.490,631] <inf> audio_datapath: Pres comp state: WAIT
HL [00:00:03.542,175] <wrn> audio_datapath: Data received, total under-runs: 47
HL [00:00:03.640,350] <inf> audio_datapath: Pres comp state: INIT
HL [00:00:03.641,296] <inf> audio_datapath: Pres comp state: MEAS
HL [00:00:03.750,122] <inf> audio_datapath: Pres comp state: WAIT
HL [00:00:03.230,133] <inf> audio_datapath: Pres comp state: WAIT
HL [00:00:03.280,120] <dbg> le_audio_rx: le_audio_rx_data_handler: ISO RX SDUs: Ch: 0 Total: 200 Bad: 21 Size mismatch 21
HL [00:00:03.302,185] <wrn> audio_datapath: Data received, total under-runs: 43
HL [00:00:03.371,276] <inf> audio_datapath: Pres comp state: INIT
HL [00:00:03.380,126] <inf> audio_datapath: Pres comp state: MEAS
HL [00:00:03.490,631] <inf> audio_datapath: Pres comp state: WAIT
HL [00:00:03.542,175] <wrn> audio_datapath: Data received, total under-runs: 47
HL [00:00:03.640,350] <inf> audio_datapath: Pres comp state: INIT
HL [00:00:03.641,296] <inf> audio_datapath: Pres comp state: MEAS
HL [00:00:03.750,122] <inf> audio_datapath: Pres comp state: WAIT
uart:~$ HL [00:00:03.852,172] <wrn> audio_datapath: Data received, total under-runs: 50
HL [00:00:03.890,136] <inf> audio_datapath: Pres comp state: INIT
HL [00:00:03.900,726] <inf> audio_datapath: Pres comp state: MEAS
HL [00:00:04.010,223] <inf> audio_datapath: Pres comp state: WAIT
HL [00:00:04.032,196] <wrn> audio_datapath: Data received, total under-runs: 54
HL [00:00:04.150,146] <inf> audio_datapath: Pres comp state: INIT
HL [00:00:04.160,156] <inf> audio_datapath: Pres comp state: MEAS
HL [00:00:04.270,141] <inf> audio_datapath: Pres comp state: WAIT
HL [00:00:04.280,059] <dbg> le_audio_rx: le_audio_rx_data_handler: ISO RX SDUs: Ch: 0 Total: 300 Bad: 31 Size mismatch 31
HL [00:00:04.352,172] <wrn> audio_datapath: Data received, total under-runs: 58
HL [00:00:04.410,125] <inf> audio_datapath: Pres comp state: INIT
HL [00:00:04.420,135] <inf> audio_datapath: Pres comp state: MEAS
HL [00:00:03.852,172] <wrn> audio_datapath: Data received, total under-runs: 50
HL [00:00:03.890,136] <inf> audio_datapath: Pres comp state: INIT
HL [00:00:03.900,726] <inf> audio_datapath: Pres comp state: MEAS
HL [00:00:04.010,223] <inf> audio_datapath: Pres comp state: WAIT
HL [00:00:04.032,196] <wrn> audio_datapath: Data received, total under-runs: 54
HL [00:00:04.150,146] <inf> audio_datapath: Pres comp state: INIT
HL [00:00:04.160,156] <inf> audio_datapath: Pres comp state: MEAS
HL [00:00:04.270,141] <inf> audio_datapath: Pres comp state: WAIT
HL [00:00:04.280,059] <dbg> le_audio_rx: le_audio_rx_data_handler: ISO RX SDUs: Ch: 0 Total: 300 Bad: 31 Size mismatch 31

My question Is it possible to do advertising while maintaining audio quality?

If yes, could you guide me or provide example code to show how to achieve this?

I would really appreciate your help.

Thanks.

Here is my board and SDK information:

Board: nRF5340 Audio DK

SDK: nRF Connect SDK v2.7.0

Application: nrf/applications/nrf5340_audio

Parents Reply Children
Related