fix: immediately re-arm the DMA pipeline when stopping due to nodata

Host hasn't asked us to stop streaming with altSetting, but has stopped
sending data. It may start again at any time without a new altSetting
command to re-arm the DMA. So we should re-arm immediately.

Fixes a bug where in some cases audio is streaming from host, but not
playing out.
This commit is contained in:
ktims committed 2026-11-04 16:30:58 -07:00
1 parent 245c45c682
commit bb7f701f20
1 file changed
+7 -3
+7 -3
View File
@@ -965,9 +965,13 @@ fn main() -> ! {
// TODO: we should handle unexpected NODATA differently from 'Stopping' // TODO: we should handle unexpected NODATA differently from 'Stopping'
if NODATA_FLAG.swap(false, Ordering::AcqRel) { if NODATA_FLAG.swap(false, Ordering::AcqRel) {
match uac2.handler().state.load(Ordering::Acquire) { let audio = uac2.handler();
AudioState::Stopping => uac2.handler().transition(AudioState::Stopped), audio.transition(AudioState::Stopped);
_ => uac2.handler().transition(AudioState::Stopped), // The host is still streaming (alt setting 1) so no alt setting change will
// re-arm us; re-arm now so the DMA channel is re-initialised before more data
// arrives.
if audio.alt_setting == 1 {
audio.transition(AudioState::Armed);
} }
} }