From 587ff24e86620d9dc55cbf02fe8fea0da939747c Mon Sep 17 00:00:00 2001 From: TheM14 Date: Sat, 14 Nov 2026 02:53:36 +0800 Subject: [PATCH] Fix native PCM startup stall at the queue gate The PCM queue cap was applied before the first output sample. For any input longer than about two seconds the gate could trigger while samples_out was still zero, emit() had nothing to return, and process_pcm returned without marking filter progress. The decoder thread then stopped and audio never became ready; short clips and E-AC-3 JOC were unaffected. Only apply the cap after the first output sample, and mark progress when the gate cannot emit. This keeps the EOF flush bounded without blocking startup. --- fork/files/audio/decode/ad_joc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fork/files/audio/decode/ad_joc.c b/fork/files/audio/decode/ad_joc.c index aedeeb3..6cd1c90 100644 --- a/fork/files/audio/decode/ad_joc.c +++ b/fork/files/audio/decode/ad_joc.c @@ -567,9 +567,11 @@ static void process_pcm(struct mp_filter *f) * kernel keeps a rendered-output queue but its input queue is unbounded; * without this gate a whole track can pile up and flush() at EOF renders * all of it at once. */ - if (!p->eof && p->pcm_input_samples > p->samples_out + PCM_MAX_QUEUE_SAMPLES) { + if (p->samples_out > 0 && !p->eof && + p->pcm_input_samples > p->samples_out + PCM_MAX_QUEUE_SAMPLES) { if (emit(f)) return; + mp_filter_internal_mark_progress(f); return; }