HLE: keep refilling XMA PCM buffer across zero-sample decode steps #2444
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!2444
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2444"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@Texbirds on GitHub · 2026-11-25 13:38 UTC · original
Texbirds:fix/hle-audio-xma-pump-loop→main· +99 −2 · 1 files · 1 commits · openProblem
In
crates/victory-hle/src/modules/audio.rs,pump()refillsvoice.pcmwith a singleif voice.pcm.len() < SAMPLES_PER_BLOCK && !decode(context, voice)before writing a 128-sample (SAMPLES_PER_BLOCK) block to the output ring.decode()legitimately returnstruewhile pushing zero samples in two cases:buf0 = 0), sodecode()switches to buffer 1 and returnstruewithout decoding a frame yet.start_skipcovers a full 4-subframe frame (e.g.,start_skip = 4), sodecode()drops all 512 samples of frame 0 and returnstruewithvoice.pcmstill empty.On
main,pump()does not calldecode()again for that output block; it drains 0 samples fromvoice.pcm, zero-pads the block, and emits a spurious silent 128-sample block before real audio resumes.Change
ifrefill inpump()with awhile voice.pcm.len() < SAMPLES_PER_BLOCKloop that keeps callingdecode()until a full block is available or decoding stops (returning early only whenvoice.pcmis empty so a partial tail block is still flushed).decode()returns at16so a malformed looping stream (e.g.,loop_skip >= keep) cannot spin indefinitely insidepump().decode()itself are unchanged.Test
pump_refills_across_empty_decode_steps_without_spurious_silence(synthetic in-memory silent XMA stream from the existingsilent_stream()helper, no game data):26 * SAMPLES_PER_BLOCKtotal samples (24 frame blocks + 2-block overlap tail); onmainthis produces 27 blocks (1 extra silent block).start_skip = 4subframes on the same 6-frame stream): expects22 * SAMPLES_PER_BLOCKtotal samples (5 remaining frames + 2-block overlap tail); onmainthis produces 23 blocks.@oni-swr on GitHub · 2026-11-25 14:13 UTC · original
Independent verification of #2444 at
413cf34(pure CPU)Commands:
cargo test -p victory-hle --lib,cargo clippy -p victory-hle --all-targets -- -D warnings,cargo xtask policy; merges cleanly withorigin/main940d32f.audio.rsreverted toorigin/mainwith the new test kept ->pump_refills_across_empty_decode_steps_without_spurious_silenceFAILS.AI-assisted verification by Claude Code (Claude Sonnet 5.5). No game files, dumps or hashes.
@Marvisak on GitHub · 2026-11-25 16:01 UTC · original
Automated triage for the maintainers.
Merge candidate.
pumpincrates/victory-hle/src/modules/audio.rsnow keeps callingdecodeuntil a block is full; on main a decode step that yields no samples (an input buffer switched or used up, or a skip covering a whole frame) leaves a padded silent block in the output. The loop is bounded and the new test fails on main per an independent run. CI: passing.Generated by Claude Code
@kotekompotek on GitHub · 2026-11-25 16:53 UTC · original
Semantics look right: a decode step that produces zero samples (buffer-0→buffer-1 transition, or a start-skip covering a full frame) no longer causes a spurious silent block — the pump retries up to 16 consecutive empty steps, and a
decodefailure now emits the partialpcmit has instead of returning with samples held.One edge:
emptycounts cumulative, not consecutive, zero-progress steps within a block fill (it's never reset on progress). In practice interleaved progress still reachesSAMPLES_PER_BLOCKand exits the inner loop, so the cap can only trigger on a real stall — fine as written.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.