HLE: keep refilling XMA PCM buffer across zero-sample decode steps #2442
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/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?
Imported from Marvisak/VIctory. Originally posted by Texbirds on 2026-11-25T13:38:42Z.
Problem
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.Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-25T13:58:20Z.
Review: APPROVED
Verified against
origin/main(940d32f):cargo test -p victory-hle audio::: 9/9 passed (includingpump_refills_across_empty_decode_steps_without_spurious_silence).cargo clippy -p victory-hle --all-targets -- -D warnings: 0 warnings.cargo xtask policy: 183 files ok.AI-assisted (Gemini 4 Neon).
Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T14:11:20Z.
Review: COMMENTED
HLE: keep refilling XMA PCM buffer across zero-sample stretches. Static review only: victory-gpu/victory-hle are Windows-only (D3D12/windows-sys); not compiled or tested on this macOS arm64 host. rustc 1.98.1.
Imported from Marvisak/VIctory. Originally posted by oni-swr on 2026-11-25T14:13:02Z.
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.
upstream-sync referenced this pull request2026-11-25 16:09:31 +00:00
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T16:01:03Z.
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
Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-25T16:53:46Z.
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.upstream-sync referenced this pull request2026-11-25 23:06:13 +00:00
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T02:05:45Z.
Review: COMMENTED
Reviewed and verified against
main(63bcca43) on Windows 11 — clean fix and ready to merge:pump(crates/victory-hle/src/modules/audio.rs:558-573) to loop untilvoice.pcmreachesSAMPLES_PER_BLOCK(128) or input is exhausted prevents spurious silence blocks across empty buffer transitions and full-framestart_skip/loop_start_skipsteps, flushes partial tail samples (< 128) instead of dropping them, and bounds empty decode iterations (empty >= 16).pump_refills_across_empty_decode_steps_without_spurious_silenceexercises both buffer rollover and skipped subframes cleanly.Local verification:
cargo test --locked -p victory-hle: 153/153 unit + 2/2 integration tests passedcargo clippy --locked -p victory-hle --tests -- -D warnings(default &--all-features): 0 warningscargo xtask policy: 191 files okupstream-sync referenced this pull request2026-11-26 03:05:04 +00:00
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.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.