Repository navigation
Conversation
… 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>
…tead of filling forever Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Tested current PR head
The test uses a synthetic silent XMA stream and in-memory ring, so it does not cover real title audio, media assets, or a host audio device. |
mercuryVM
left a comment
There was a problem hiding this comment.
Tested 1054fe8 on Windows 11, RTX 5070, MSVC: the workspace passes (196 outside victory-shader), including xma_read_blocks_past_the_ring_end_wrap, which ends well inside its 5 s guard.
The write block and advance_read were already taken modulo the ring, so comparing against the title's raw read block meant a value ≥ size was never reached. A looping stream then filled forever while holding the voice lock. % size makes the three agree. The test is built so that a regression fails instead of hanging: the pass runs on its own thread with a timeout and a forced "full" fallback.
No issues found.
AI-assisted (Claude Code).
…g's end wraps instead of filling forever Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
As @Exorion1er noted, #536 contains this change and its test unchanged, plus the write-block wrap. Merging both would give two tests with the same name, so I'm closing this one in favour of #536. Thanks @jeremygold02 and @mercuryVM for testing it; those results apply to #536's first commit as is. |
What
pumpincrates/victory-hle/src/modules/audio.rscompares the write block with the title'sread block taken modulo the ring size (
context.field(9, 0, 5) % size), as the write block(
(write + 1) % size) and command 18 (advance_read) already are. One line and a comment.xma_read_blocks_past_the_ring_end_wrap: a context set up like the one inxma_contexts_decode_into_their_output_rings(the synthetic silent stream, a ring of fourblocks), but looping forever over the whole stream (loop count 255) and with read block 6. It
runs an XMA pass on a thread of its own and requires it to end within 5 s, with blocks 0 and 1
written, blocks 2 and 3 untouched, the write block on 2 and the ring no longer writable. If the
pass does not end, the test clears the context's "writable" bit as a full ring would, so the
stuck pass ends, the contexts are released, and the test fails without holding up the rest of
the suite.
Why
A pass fills a voice's ring until the write block (word 0, bits 27-31) comes round to the read
block (word 9, bits 0-4). The write block wraps modulo the ring size (word 0, bits 22-26), but a
read block the title set up at or past the size was compared as it was: no write block ever
equalled it, and "writable" was never cleared. With an input that ends, the pass went round the
ring until the input ran out, writing over blocks the title had not read yet. With a stream that
loops forever it never returned. It holds that voice's lock while it runs, so:
good; titles send them from their mixer thread;
AcpHalReleaseShapeContextswaited for good for the context arrays' lock.Why modulo, not a clamp or an error: the module already treats both offsets as positions on the
ring. The write block wraps, and command 18 already takes the read block modulo the size, so a
read block out of range is brought into range the first time the title advances it; the passes
before that now agree with it. Xenia's XMA context decoder, which reads the same fields, does
the same: it puts both offsets on its ring buffer, whose
set_read_offsetandset_write_offsettake them modulo the capacity. I know of no documented error status for this case. A pass now
writes at most one ring's worth of blocks (plus one, see below).
Also checked in
pump, not changed: every turn of its loop writes a block and moves the writeblock on, whatever the input does, so with the read block in range a pass ends within one ring
however the input buffers and loops are set up. A write block at or past the ring size is not
this bug (the pass still ends) but has a cost of its own: the first block of the pass is written
past the ring's end before the write block wraps.
Tested
Windows 11, NVIDIA GeForce RTX 5080, Rust 1.98.1.
cargo test -p victory-hle -- modules::audiofails the newtest after 5.0 s ("the XMA pass never ended"); the five other audio tests pass. All of
cargo test -p victory-hle -- --test-threads=4: 86 passed, 1 failed (the new test), finished in5.02 s, so the stuck pass is ended and the rest of the crate runs.
cargo test -p victory-hle -- modules::audiogives 6 passed, 0 failed; the new testtakes 0.003 s (
--report-time).cargo test --workspace -- --test-threads=4, run side by side: main 264 passed, 0 failed,4 ignored; this branch 265 passed (the new test), 0 failed, 4 ignored.
cargo clippy -p victory-hle --all-targets: the same single warning on main and here (inxmem.rs), nothing inaudio.rs.rustfmt --checkonaudio.rs: nothing in the changed lines(the same older differences at
Xma::pump,dump_inputand inaudio/capture.rsas on main).cargo xtask policy: 151 files ok.Not tested
was not observed; the choice follows the module's write side and Xenia.
Open PRs on this file: #88 (
advance_read), #112 (formatting), #130 (a profiler scope indecode), #194 (the loop skip indecode), #237 (the heap lock inpumpanddecode) and thedraft integration #231 each merge with this branch without a textual conflict in
audio.rs(
git merge-tree; not tested together); none of them changes the comparison inpump.AI-assisted (Claude Code, Claude Opus 5.5). No game files were used.