-
Notifications
You must be signed in to change notification settings - Fork 6.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
samples: Add USB Audio to broadcast audio source #64601
samples: Add USB Audio to broadcast audio source #64601
Conversation
abdb9b2
to
b91d76d
Compare
Moved the PR out of draft to get some initial reviews. There are some glitches on the USB Audio side (periodic approx 10 secs of clean flow and audio, then 2-3 secs of missing data coming from USB) which may require updates to how the USB data flow is handled. |
samples/bluetooth/broadcast_audio_source/boards/nrf5340_audio_dk_nrf5340_cpuapp.conf
Outdated
Show resolved
Hide resolved
Moving the PR to draft until I have the encoder in a separate thread and addressed the issues mentioned in comments above |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The USB issues are related to following remark from nRF5340 Product Specification:
"If the EasyDMA transfer on the isochronous endpoint is not completed before the next SOF event, the result of the transfer is undefined."
Because lc3_encode() can clearly execute for longer than 1 ms, it is completely unacceptable to have it executing in cooperative thread context.
ok - offloaded to a separate thread and everything flows smoothly now (cleaning up the PR). There are a very few occasional glitches, probably because we don't have sample rate conversion to compensate for clock drifting/mismatch - but rare enough for the sample IMO. Working on reintroducing multi stream (stereo) and the rest of the change requests. |
99a7c2f
to
c9039ea
Compare
samples/bluetooth/broadcast_audio_source/boards/nrf5340_audio_dk_nrf5340_cpuapp.conf
Outdated
Show resolved
Hide resolved
samples/bluetooth/broadcast_audio_source/boards/nrf5340_audio_dk_nrf5340_cpuapp.conf
Outdated
Show resolved
Hide resolved
c6cf525
to
492fe1c
Compare
212b3e5
to
f8a7708
Compare
@Thalley and @tmon-nordic - it seems to be in a stable state now with the tests I made. Would you be able to re-review and possibly accept further improvements (e.g. to USB corner case handling) to come as a follow-up? |
samples/bluetooth/broadcast_audio_source/boards/nrf5340_audio_dk_nrf5340_cpuapp.conf
Outdated
Show resolved
Hide resolved
samples/bluetooth/broadcast_audio_source/boards/nrf5340_audio_dk_nrf5340_cpuapp.conf
Outdated
Show resolved
Hide resolved
samples/bluetooth/broadcast_audio_source/boards/nrf5340_audio_dk_nrf5340_cpuapp.conf
Outdated
Show resolved
Hide resolved
samples/bluetooth/broadcast_audio_source/boards/nrf5340_audio_dk_nrf5340_cpuapp.conf
Outdated
Show resolved
Hide resolved
samples/bluetooth/broadcast_audio_source/boards/nrf5340_audio_dk_nrf5340_cpuapp.conf
Outdated
Show resolved
Hide resolved
printk("Initialized ring buf %zu: capacity: %u\n", i, | ||
ring_buf_capacity_get(&(streams[i].audio_ring_buf))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
printk("Initialized ring buf %zu: capacity: %u\n", i, | |
ring_buf_capacity_get(&(streams[i].audio_ring_buf))); | |
printk("Initialized ring buf %zu: capacity: %u\n", i, | |
ring_buf_capacity_get(&(streams[i].audio_ring_buf))); |
f8a7708
to
62150b2
Compare
62150b2
to
2f6d2e4
Compare
samples/bluetooth/broadcast_audio_source/boards/nrf5340dk_nrf5340_cpuapp.conf
Show resolved
Hide resolved
samples/bluetooth/broadcast_audio_source/boards/nrf5340_audio_dk_nrf5340_cpuapp.conf
Show resolved
Hide resolved
2f6d2e4
to
3d341a2
Compare
(last push was just commit message fix) |
3d341a2
to
281f9fb
Compare
Adds support for using a connected host to broadcast audio via USB Audio. Offload LC3 encoding to separate thread. Signed-off-by: Lars Knudsen <[email protected]>
281f9fb
to
175eff1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good enough as is, with some improvements that can be applied
default n | ||
depends on ENABLE_LC3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than doing
CONFIG_USE_USB_AUDIO_INPUT=y
in samples/bluetooth/broadcast_audio_source/boards/nrf5340_audio_dk_nrf5340_cpuapp.conf
, you could follow the approach above and do
default y if SOC_NRF5340_CPUAPP
So that is is applied for both the regular and audio kit
# Use USB Audio as input | ||
CONFIG_USE_USB_AUDIO_INPUT=y | ||
CONFIG_USB_DEVICE_PRODUCT="Zephyr Broadcast Source" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be interesting to find a way to set CONFIG_USB_DEVICE_PRODUCT="Zephyr Broadcast Source"
for any device that enables USB, and not just the nRF5340 ADK
if (streams[i].lc3_encoder == NULL) { | ||
printk("ERROR: Failed to setup LC3 encoder - wrong parameters?\n"); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we return here, or allow only setting up a subset of the encoders?
@tmon-nordic could you check if you could approve? GH still tells me you have a change requested. If anything, could it be a followup PR? |
LC3 processing was moved to preemptible thread, resolving USB issues
I just dismissed the review because the USB issue is fixed. The problem was simply preventing USBD workqueue from processing events within the deadline (SOF = 1 ms). The PR looks fine to me, but I am not really the correct person to approve it. |
Adds support for using a connected host to
broadcast audio via USB Audio.
Offload LC3 encoding to separate thread.