Skip to content

[BUNDLE] HLE audio and input (XMA, APU, WASAPI capture, GameInput): #194 #528 #536 #478 #197 #361 #613 - #1389

Closed
MamaLeVrai wants to merge 17 commits into
Marvisak:mainfrom
MamaLeVrai:bundle/hle-audio-input
Closed

MamaLeVrai wants to merge 17 commits into
Marvisak:mainfrom
MamaLeVrai:bundle/hle-audio-input

Conversation

@MamaLeVrai

@MamaLeVrai MamaLeVrai commented Nov 24, 2026 •

Copy link
Copy Markdown

One PR in place of 7. The HLE PRs on audio and input: XMA loop and write-block handling, APU pointer validation, WASAPI capture guards, VICTORY_KEYS on a connected pad, and the order of GameInput readings. Every head is merged unchanged onto main (ffe310e), and the result is built and tested together.

For reviewers and for anyone verifying with an agent (Claude, Codex, a person): this is a [BUNDLE] PR. The re-verification commands are below, so one run covers all of it.

What is inside

PR Author Head Title
#194 Maraco91 985d8d4b0 Audio: an XMA loop's skip is of its first frame, not of its last
#528 pushkarreddyy 33495ff06 HLE: validate null pointer in ApuIsVirtualAddressValid and overflow in ApuAlloc
#536 AnoHunted 7a5d85e6a Audio: an XMA write block past the ring's end wraps before the first write
#478 nathanbzrr 7ac2760d3 Audio capture: guard WASAPI timestamp errors/underflow, null 0-frame slice UB, unbounded silence allocation, and WAV header u32 overflow
#197 Alpaca-exe 64484b426 Input: apply VICTORY_KEYS to a connected host pad too
#361 booomxd 3f5eff576 Input: with no device, previous and next readings walk every device in time order
#613 Quat3rnion 7da55befe HLE: serialize device callbacks across delivery threads

All of them merge with no conflict and no change of mine.

Left out, and why

Verification

Windows 11, RX 6950 XT, Rust 1.98.1 (the pinned toolchain):

Check Result
cargo clippy --workspace --all-targets --locked -- -D warnings clean
cargo clippy --workspace --all-targets --all-features --locked -- -D warnings clean
cargo test --workspace --locked 350 passed, 0 failed, 6 ignored (main: 342 passed, 6 ignored)

The title was not run, so this says nothing about in-game effect. No game data is used or committed.

Re-verify in one go

git fetch https://github.com/MamaLeVrai/VIctory.git bundle/hle-audio-input
git checkout FETCH_HEAD
cargo clippy --workspace --all-targets --locked -- -D warnings
cargo clippy --workspace --all-targets --all-features --locked -- -D warnings
cargo test --workspace --locked

To confirm that no component PR moved since this was built, compare each Head above with gh pr view <n> --repo Marvisak/VIctory --json headRefOid. If one differs, the branch needs a rebuild: merge the new head in the same order.

If this lands

The component heads are in the history unchanged, so each PR's commits and authorship are kept and GitHub should mark them merged. Merging them one by one instead works too, with the exceptions noted above.

AI-assisted (Claude Code); no game data.

🤖 Generated with Claude Code

Maraco91 and others added 17 commits November 24, 2026 02:17
When a frame ended a loop, decode cut it at the loop's end subframe, set
the loop's skip (the subframes of the loop's first frame that lie before
the loop) and then took that skip out of the frame in hand: the loop's
last. So the head of the last frame was dropped instead, and the first
frame played from its start, with the audio before the loop in it. The
number of samples came out the same; the seam did not.

The pending skip is still applied to the frame in hand, and the loop's
skip is set after it, for the frame decoded next.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
… forever

The decoder fills an XMA voice's output ring until the write block
(word 0, bits 27-31) comes round to the title's read block (word 9,
bits 0-4). The write block wraps modulo the ring size (word 0, bits
22-26), and so does a read block moved on by command 18, but a read block
the title set up at or past the ring's end was compared as it was: no
write block ever equalled it. With a stream that loops forever the pass
never ended, holding that voice's lock, so the title's next command on
the voice (advance, disable) waited for good, and releasing the context
arrays did too.

Take the read block modulo the ring size as well, as the write side
already does. A test sets up read block 6 on a ring of four with an
endless loop and requires the pass to end within seconds, with blocks 0
and 1 filled.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…slice UB, unbounded silence allocation, and WAV header u32 overflow
…write

The write block (context word 0, bits 27-31) was used as it is for the first
block of a pass, so one at or past the ring size (bits 22-26) was written
past the ring's end, possibly into another APU allocation, before it wrapped
with (write + 1) % size. Take it modulo the ring first, as the read block is
taken, and as advance_read does.
Registration and poll threads both called deliver directly, so an initial enumeration callback and a hotplug could run at the same time; GameInput guarantees one callback at a time in order. Events now go through one queue in Hub state, with a single thread draining it; callbacks that enqueue more events join the same loop instead of nesting. Add a regression that holds a registration callback open while another thread polls and checks peak concurrency is one.
Run blocking enumeration on the caller when another delivery is active. Hold hotplug events for that registration until enumeration ends, and track inline callbacks for unregistration.
Merges Marvisak#194 Marvisak#528 Marvisak#536 Marvisak#478 Marvisak#197 Marvisak#361 Marvisak#613 onto main (ffe310e), each head
unchanged, no conflicts, no changes of mine. cargo clippy --workspace
--all-targets --locked -- -D warnings, with and without --all-features, is
clean and cargo test --workspace --locked passes (350 passed, 6 ignored;
main has 342 passed, 6 ignored).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings November 24, 2026 17:41

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@sinan-cmyk

Copy link
Copy Markdown

Runtime boot check on real hardware with a retail dump

Result: no difference from main in this test.

I merged head 9b39340 onto main ffe310e (clean merge), built it (release), and ran victory run <title exe> --execute with an empty data folder for 100 s, without any input. I compared the run with main built and run the same way.

main ffe310e this PR
Reaches the first-boot screens yes yes
Caption at 100 s (one sample) 30 fps, 12 draws/frame 30 fps, 12 draws/frame
Frames presented 2,048 2,048
crashes.log entries 0 0
Committed memory 11.1 GB 11.1 GB

Warnings: 7, the same kinds and counts as on main. 0 errors.

Limits. Without input, the title stays on the first-boot screens. This run does not exercise saves, the intro video, the start screen, loading or the world. It shows only that the change does not break startup or the first menus on this machine. I did not run the PR's tests.

Machine: Ryzen 7 7800X3D, RTX 4070 SUPER, Windows 11 25H2, game 1.0.2.1. AI-assisted (Claude Code).

@Marvisak

Copy link
Copy Markdown
Owner

Automated triage for the maintainers. Closing because this pull request re-packages other open pull requests. Each of those is reviewed on its own, so a bundle cannot be merged.

If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.

@Marvisak Marvisak closed this Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.