diff options
| author | HiFiPHile <[email protected]> | 2026-08-25 09:29:07 +0200 |
|---|---|---|
| committer | HiFiPHile <[email protected]> | 2026-08-25 09:29:07 +0200 |
| commit | 62243107cec5e48f447661ea7a17969d05f76adb (patch) | |
| tree | 21117acb436d1009c7d1ea1c0c77a4289adc5b6d /examples/host/audio_host/src | |
| parent | 0fd39954d7800777774c17617e41825e5a3561da (diff) | |
fix(audio): keep stream state consistent on control failures
Route asynchronous activation and sampling-frequency failures through the stream error callback. Keep a running stream active when SET_INTERFACE alt 0 cannot be submitted so stop can be retried without diverging from device state.
Signed-off-by: HiFiPHile <[email protected]>
Diffstat (limited to 'examples/host/audio_host/src')
| -rw-r--r-- | examples/host/audio_host/src/audio_app.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/examples/host/audio_host/src/audio_app.c b/examples/host/audio_host/src/audio_app.c index 941248e99..0c4ed8a23 100644 --- a/examples/host/audio_host/src/audio_app.c +++ b/examples/host/audio_host/src/audio_app.c @@ -348,12 +348,18 @@ static void audio_app_restart_stream(uintptr_t param) { } } -// Invoked when an isochronous transfer fails: the stream was stopped by the -// driver, re-open it after a short delay so the device can recover. +// Invoked when stream activation or an isochronous transfer fails: the stream +// was stopped by the driver, re-open it after a short delay so the device can +// recover. void tuh_audio_err_cb(uint8_t idx, uint8_t stream_idx, uint16_t xferred_bytes) { (void)xferred_bytes; err_cb_count++; - printf(" AUDIO transfer error: addr=%u stream=%u xferred_bytes=%u\r\n", idx, stream_idx, (unsigned)xferred_bytes); + if (stream_idx == cap_stream_idx) { + mic_ready = false; + } else if (stream_idx == spk_stream_idx) { + spk_ready = false; + } + printf(" AUDIO stream error: idx=%u stream=%u xferred_bytes=%u\r\n", idx, stream_idx, (unsigned)xferred_bytes); app_defer_ms_async(100, (app_defer_func_t)audio_app_restart_stream, ((uintptr_t)idx << 8) | stream_idx); } |
