XAudio2: a voice at a reused address drops the stale decoder's state #451
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/456"
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 ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T00:31:35Z.
Fixes #328.
An
IXAudio2engine released withoutDestroyVoiceon its voices leaves their entries inXMA/DECODED_VOICES(andDECODED_LIVE_COUNTincremented, theDecodedCallbackleaked). When Windows hands the same address to a laterCreateSourceVoice, the new voice inherited them: a plain PCM voice'sSubmitSourceBuffercalls were fed to the stale Opus/XMA decoder.evict_voice()now forgets both tables on every successful create, on the decoded path (create_decoded_voice) and the plain/silent path, before the new entry is inserted.destroy_voiceshares the same take/release helpers, so teardown is unchanged.What is in it
crates/xcl/src/hle/xaudio2.rs:take_decoded_voice/release_decoded_handle/evict_voicehelpers;evict_voicecalled after*ppon both create paths;destroy_voicerefactored onto the helpers; one unit test that plants staleXMA+DECODED_VOICESentries at a fake voice address and checks both maps and the live count after eviction.Tested
x86_64-pc-windows-msvc, debug build:cargo test -p xcl --lib xaudio2: 10 passed, 0 failed (includes the new test; the real-engine XAudio2 tests also pass)cargo test --workspace -- --test-threads=4: 677 passed, 0 failed, 41 ignoredno wave64recompiler GPU tests (ran on the iGPU in the #42 report)scripts/smoke.ps1 -Seconds 60,cargo build --release -p xcl:main
a6f5f7a:this PR's head
00f0fd5(rerun after a first cold-cache pass showed 685 frames; warm-cache numbers below):Not tested
AI use
Imported from ivall/xcl. Originally posted by shdann on 2026-11-24T00:47:05Z.
Review: COMMENTED
crates/xcl/src/hle/xaudio2.rs:1843asserts that the process has zero decoded voices after the test removes its own voice. The Opus and XMA2 lifetime tests in the same binary can each hold a decoded voice at that point. With parallel tests, eviction can succeed and the count can still be one. The preceding two assertions already check removal of this voice by address. Please keep those assertions and check the global count in an isolated test process if counter coverage is needed. Static review of00f0fd5with OpenAI Codex (GPT-6).Imported from ivall/xcl. Originally posted by ethandepstein-del on 2026-11-24T01:02:11Z.
Code audit + NVIDIA RTX 5080 test run on
00f0fd5e08420abac8e000988ea7f919634d466f(fixes #328):Review
Looks clean —
evict_voiceis called on bothcreate_decoded_voiceandcreate_source_voicebefore inserting new entries, and sharingtake_decoded_voice/release_decoded_handlewithdestroy_voicekeeps the teardown logic in one place.evict_voice_drops_stale_entries_at_a_reused_address, assertingDECODED_LIVE_COUNT == 0could flake if another test inxaudio2::testsever holds a live decoded voice concurrently under--test-threads=4; comparing against a pre-test snapshot or delta would avoid that.)Tested
rustc 1.100.0(MSVC), debug build.cargo build --workspace && cargo test --workspace -- --test-threads=4: 677 passed, 0 failed, 41 ignored.hle::xaudio2::tests::evict_voice_drops_stale_entries_at_a_reused_address: passed.SKIPPEDGPU tests (2, wave32-only adapter):gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask: no wave64,gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware: no wave64.Not tested
scripts/smoke.ps1run (test suite only).AI use: code review and test run orchestrated with Antigravity (Gemini 4 Neon) on the hardware listed above.
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T01:06:51Z.
Re-ran the regression smoke on the new head
017515c(test-only change per review — dropped the globalDECODED_LIVE_COUNTassert that raced parallel Opus/XMA2 tests; the per-address assertions stay). RTX 3060 Ti, GTA VI 1.0.2.1, 60 s:cargo test -p xcl --lib xaudio2: 10 passed, 0 failed.mainreaches on Windows; the obstacle is replaced vtables — proposal: proxies #172Imported from ivall/xcl. Originally posted by alpz1000 on 2026-11-24T01:40:10Z.
Independent parallel XAudio2 test check at PR head
017515ca0b8f92354c4d06db550e93dcc1aa0288, including the follow-up that removes the global live-count assertion.Tested on Windows 11 Home 26200.9974, Intel Core i5-8400, Rust 1.100.0 x86_64-pc-windows-msvc, debug.
cargo test --locked -p xcl --lib xaudio2 -- --test-threads=4 --nocapturepassed all 10 tests, including the reused-address eviction regression and the tests using system XAudio2. Then I ran that same lib test executable withxaudio2 --test-threads=4in 20 fresh processes. All 20 runs passed all 10 tests with no skips.Not tested: the prior revision's failure rate, full workspace, retail gameplay, or an actual engine-teardown/address-reuse sequence. The stale-address regression uses synthetic state.
AI use: OpenAI Codex (GPT-6) ran the local tests and drafted the report.
Imported from ivall/xcl. Originally posted by ryosen0 on 2026-11-24T01:57:24Z.
Serial-test confirmation on NVIDIA: head
017515cmerged ontomain508a0c7(clean), with #468 and #508 also applied. RTX 3060 Ti 8 GB, Ryzen 7 9800X3D, driver 32.0.16.1742, Windows 11.cargo test -p xcl --lib -- --test-threads=1 title_textures xaudio2 acphal: 27 passed, 0 failed - the stale-decoder eviction test passes with the global live-count assert removed (the removal is right: the count is process-global, parallel tests legitimately move it).--test-threads=1the xaudio2 set is stable here; the race the removed assert caught was test-only, as the review said.Not tested: a retail voice-reuse scenario end-to-end (no audible check).
AI use: GPT-6.2 Astra (API model selector) in DSH ran the tests and wrote this comment; the human contributor reviewed it.
Imported from ivall/xcl. Originally posted by woreksami on 2026-11-24T02:16:11Z.
Test report: on this machine this PR is what made the title's sound continuous (the choppy sound from #260).
Tested
XCL_NETWORK=0,XCL_PSO_WAIT_MS=150,XCL_DXC_THREADSunsetmain508a0c7+ #214, #267, #300, #503, #468: narration and loading-screen music cut out after 1–2 s, in every run.main9ce2070+ #214 (960162e), #267 (043d1f7), #300 (9507d05), #503 (78f5510), #468 (0d407cf), #572 (14d638a) + this PR (017515c): three runs, the sound was continuous through the menus and the loading screen ("pretty much all of it", by ear). This PR is the only audio change between the two trees.xapustill logs a single1 Opus packets decodedline per run in both trees, so the continuous sound does not come through that path here.cargo test --release -p xcl --libon the merged tree: 658 passed, 0 failed, 21 ignored.Not tested
main(the before/after trees also differ by #451 and #572); AMD; a meter on the audio output (heard by ear only); the workspace suite andscripts/smoke.ps1.AI use
Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-11-27T08:45:53Z.
Nothing has happened on this PR for 3 days, so it is marked
staleand will be closed in 4 days. A push or a comment takes the mark off: rebase it ontomainif it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T03:09:26Z.
Triage (#1607) – head
017515cNo open or merged PR fixes #328; main's
xaudio2.rsstill only removesXMA/DECODED_VOICESentries indestroy_voice, so a voice at a reused address inherits them.evict_voiceruns right after creation and before the new entries are inserted in bothcreate_source_voiceandcreate_decoded_voice; freeing the staleDecodedCallbackthere is safe because the old engine's voice is gone. No problems found in the diff. The PR conflicts with main and thePR descriptioncheck fails.Recommendation: keep open.
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
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.