fix(multimodal): stabilize downstream audio playback

- add configurable prebuffer and adaptive rebuffer for packet jitter
- mute stalled output, auto-clear I2S DMA, and abort inactive playback after 3 seconds
- discard stale-generation packets and add optional downstream diagnostics
This commit is contained in:
chenjintao
2026-08-11 15:25:26 +08:00
parent b60a0373ba
commit 3ce9b38098
5 changed files with 703 additions and 10 deletions
+48
View File
@@ -1101,6 +1101,54 @@ menu "Example Configuration"
the ES8311 output path. This keeps the PA control behavior
unchanged while suppressing idle speaker noise.
config MULTIMODAL_AUDIO_DOWNSTREAM_ACTIVE_STALL_MUTE_MS
int "Downstream active response stall timeout (ms)"
default 3000
range 500 10000
help
Abort the current playback generation when neither audio
output nor downstream response packets advance for this
long. The output is muted first so a stalled response
cannot leave stale DMA audio audible indefinitely.
config MULTIMODAL_AUDIO_DOWNSTREAM_PREBUFFER_MS
int "Downstream playback prebuffer (ms)"
default 160
range 0 1000
help
Audio accumulated before initial playback. This adds a
small first-audio delay in exchange for absorbing normal
Wi-Fi and server delivery jitter.
config MULTIMODAL_AUDIO_DOWNSTREAM_REBUFFER_GAP_MS
int "Downstream underrun detection delay (ms)"
default 120
range 20 500
help
Continuous empty-queue interval that mutes the output and
returns playback to buffering instead of restarting on
every isolated packet.
config MULTIMODAL_AUDIO_DOWNSTREAM_MAX_REBUFFER_MS
int "Maximum adaptive downstream recovery buffer (ms)"
default 640
range 160 2000
help
Maximum audio accumulated after repeated queue underruns.
The recovery target grows from twice the initial prebuffer
up to this limit for an unstable response.
config MULTIMODAL_AUDIO_DOWNSTREAM_DIAGNOSTICS_ENABLE
bool "Enable downstream audio diagnostics"
default n
help
Collect and report low-rate downstream audio timing, queue
depth, queue starvation, enqueue failure, and playback
failure statistics. Active responses also report a
once-per-second wait snapshot when no audio advances.
Disabled by default to avoid diagnostic logging and
per-packet accounting in production builds.
config MULTIMODAL_AUDIO_DOWNSTREAM_PLAYBACK_TASK_STACK
int "Downstream playback task stack (bytes)"
default 12288