From edb883a0c017ebc6b96f617ab032ffebe9789525 Mon Sep 17 00:00:00 2001 From: HiFiPHile Date: Tue, 25 Aug 2026 09:27:36 +0200 Subject: fix(audio): retain stream state when stop fails Clear the started state only after SET_INTERFACE alt 0 succeeds. A failed control transfer can then be retried instead of leaving software and device state inconsistent. Signed-off-by: HiFiPHile --- src/class/audio/audio_host.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/class/audio/audio_host.c b/src/class/audio/audio_host.c index 72c00576f..6e1a6a68c 100644 --- a/src/class/audio/audio_host.c +++ b/src/class/audio/audio_host.c @@ -1175,7 +1175,7 @@ bool tuh_audio_stop(uint8_t dev_idx, uint8_t stream_idx) { TU_VERIFY(p_audio->mounted, false); tuh_audio_stream_t *s = audioh_get_stream_by_idx(p_audio, stream_idx); - TU_VERIFY(s && s->running, false); + TU_VERIFY(s && s->state == STREAM_STATE_READY, false); // The in-flight transfer (if any) completes and its data is discarded; // queued frames are dropped as well. The interface is deactivated (alt 0) @@ -1184,6 +1184,7 @@ bool tuh_audio_stop(uint8_t dev_idx, uint8_t stream_idx) { tu_edpt_stream_clear(&s->edpt); s->rem_acc = 0; // restart the pacing accumulator on the next tuh_audio_start() + // Keep stop retryable if EP0 is busy and SET_INTERFACE cannot be submitted. const audioh_stream_map_t *map = &s->map[s->active_config]; return tuh_interface_set(s->daddr, map->itf_num, 0, audioh_stream_stop_complete, (uintptr_t)s); } -- cgit v1.3.1