From bb7f701f20e63c14af5345569fe875df7142c59b Mon Sep 17 00:00:00 2001 From: Keenan Tims Date: Wed, 4 Nov 2026 16:30:58 -0700 Subject: [PATCH] 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. --- firmware/src/main.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/firmware/src/main.rs b/firmware/src/main.rs index 21c9b26..c1511d4 100644 --- a/firmware/src/main.rs +++ b/firmware/src/main.rs @@ -965,9 +965,13 @@ fn main() -> ! { // TODO: we should handle unexpected NODATA differently from 'Stopping' if NODATA_FLAG.swap(false, Ordering::AcqRel) { - match uac2.handler().state.load(Ordering::Acquire) { - AudioState::Stopping => uac2.handler().transition(AudioState::Stopped), - _ => uac2.handler().transition(AudioState::Stopped), + let audio = uac2.handler(); + audio.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); } }