samples: Bluetooth: Refactor TX for unicast audio client

Refactored the unicast audio client sample to use a
separate thread for TXing, rather than the system workqueue.

This allows us to do blocking waiting operations like
buf = net_buf_alloc(&tx_pool, K_FOREVER);
and also splits the responsibility of TXing to a new
file as well.

LC3 handling have also been moved to a new file, so
that it does not pollute the source code for non-LC3
supported builds. This also fixes various issues and
improves the LC3 handling in the sample.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This commit is contained in:
Emil Gydesen 2024-05-28 15:04:16 +02:00 committed by Johan Hedberg
commit 038fc8b6ac
10 changed files with 553 additions and 346 deletions

View file

@ -11,6 +11,9 @@ target_sources(app PRIVATE
${unicast_client_path}/src/main.c
)
zephyr_sources_ifdef(CONFIG_LIBLC3 ${unicast_client_path}/src/stream_lc3.c)
zephyr_sources_ifdef(CONFIG_BT_AUDIO_TX ${unicast_client_path}/src/stream_tx.c)
target_sources(app PRIVATE
src/unicast_client_sample_test.c
src/test_main.c

View file

@ -1,16 +1,2 @@
# This file content is just a copy of the unicast client sample prj.conf
CONFIG_BT=y
CONFIG_LOG=y
CONFIG_BT_CENTRAL=y
CONFIG_BT_AUDIO=y
CONFIG_BT_BAP_UNICAST_CLIENT=y
CONFIG_BT_ISO_TX_BUF_COUNT=4
# Support an ISO channel per ASE
CONFIG_BT_ISO_MAX_CHAN=4
CONFIG_BT_BAP_UNICAST_CLIENT_GROUP_STREAM_COUNT=4
CONFIG_BT_BAP_UNICAST_CLIENT_ASE_SNK_COUNT=2
CONFIG_BT_BAP_UNICAST_CLIENT_ASE_SRC_COUNT=2
CONFIG_BT_KEYS_OVERWRITE_OLDEST=y
CONFIG_BT_EXT_ADV=y
# Please build using the sample configuration file:
# ${ZEPHYR_BASE}/samples/bluetooth/uncast_audio_client/prj.conf

View file

@ -14,7 +14,11 @@ source ${ZEPHYR_BASE}/tests/bsim/compile.source
if [ "${BOARD_TS}" == "nrf5340bsim_nrf5340_cpuapp" ]; then
app=samples/bluetooth/bap_unicast_server sysbuild=1 compile
app=samples/bluetooth/bap_broadcast_source sysbuild=1 compile
app=tests/bsim/bluetooth/audio_samples/bap_unicast_client sysbuild=1 compile
app=tests/bsim/bluetooth/audio_samples/bap_unicast_client \
sample=${ZEPHYR_BASE}/samples/bluetooth/bap_unicast_client \
conf_file=${sample}/prj.conf \
conf_overlay=${sample}/boards/nrf5340_audio_dk_nrf5340_cpuapp.conf \
exe_name=bs_${BOARD_TS}_${app}_prj_conf sysbuild=1 compile
app=tests/bsim/bluetooth/audio_samples/bap_broadcast_sink sysbuild=1 \
conf_file=${ZEPHYR_BASE}/samples/bluetooth/bap_broadcast_sink/prj.conf \
exe_name=bs_${BOARD_TS}_${app}_prj_conf sysbuild=1 compile
@ -24,7 +28,9 @@ else
app=samples/bluetooth/bap_broadcast_source conf_overlay=overlay-bt_ll_sw_split.conf \
exe_name=bs_${BOARD_TS}_${app}_prj_conf sysbuild=1 compile
app=tests/bsim/bluetooth/audio_samples/bap_unicast_client \
conf_overlay=${ZEPHYR_BASE}/samples/bluetooth/bap_unicast_client/overlay-bt_ll_sw_split.conf \
sample=${ZEPHYR_BASE}/samples/bluetooth/bap_unicast_client \
conf_file=${sample}/prj.conf \
conf_overlay=${sample}/overlay-bt_ll_sw_split.conf \
exe_name=bs_${BOARD_TS}_${app}_prj_conf sysbuild=1 compile
app=tests/bsim/bluetooth/audio_samples/bap_broadcast_sink \
conf_file=${ZEPHYR_BASE}/samples/bluetooth/bap_broadcast_sink/prj.conf \