summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHiFiPHile <[email protected]>2026-08-25 09:27:36 +0200
committerHiFiPHile <[email protected]>2026-08-25 09:27:36 +0200
commitedb883a0c017ebc6b96f617ab032ffebe9789525 (patch)
tree00099df0ea3433f19cdf3920e0a1f3a6ee6f7c56 /src
parent3e3de770979b1afa375153de7c789176e39342bd (diff)
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 <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/class/audio/audio_host.c3
1 files changed, 2 insertions, 1 deletions
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);
}