XAudio2: GetState names the oldest queued buffer when the host gives none #890
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!890
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-890"
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?
@shortside on GitHub · 2026-11-24 07:44 UTC · original
shortside:xaudio2/getstate-queued-context→main· +16 −2 · 1 files · 1 commits · openUnder Wine (CrossOver 26.3),
GetStateon a decoded (XMA / Opus) source voice that has buffers queued but has not started returnsBuffersQueued = 2andpCurrentBufferContext = NULL; Windows names the first queued buffer.hle::xaudio2::tests::xma2_source_voice_decodes_and_manages_lifetimechecks for that and fails under Wine (left: 0, right: 12291=0x3003). Reported in https://github.com/ivall/xcl/issues/258#issuecomment-7124193301.XCL submits its decoded buffers with a non-null token as the context, so a null current context with buffers queued means the host did not say. When that happens,
GetStatenow names the oldest of the voice's buffers that has not ended. When the host returns a context, the mapping is unchanged, so this does nothing on Windows.What is in it
crates/xcl/src/hle/xaudio2.rs:DecodedBuffergets a submission number (NEXT_BUFFER_SEQ);get_statefalls back to the oldest live buffer when the host's current context is null andBuffersQueued != 0. +16 / -2, one commit.Tested
x86_64-pc-windows-msvcwith clang-cl / lld-link 23.1.6 and an xwin SDK 10.0.26100, Rust 1.100.0, debug. The test binary was run under Wine;mainisbeaa245, the head is this PR's commit (the runs were made before a comment-only edit to the new comment).xcl-<hash>.exe hle::xaudio2:: --test-threads=1, 3 runs each:main8 passed, 1 failed (this test) every run; head 9 passed, 0 failed every run.hle::with--skip ::gpu_on the head (skipping the 3 tests below that crash this host onmaintoo): 278 passed, 3 failed, 2 ignored; this test passes. The 3 failures fail onmainas well.--skip ::gpu_ --test-threads=1, restarted past each crash),mainvs head: 571 / 5 / 20 and 572 / 5 / 20 (passed / failed / ignored); no other test changed outcome apart from two that are flaky on this host (cpu_writes::tests::writes_land_after_the_queuefailed once onmainand passed on reruns;vram::tests::d32s8_targets_take_their_own_size_of_video_memorycrashed in themainrun and not in the head's). In this whole-lib run the head still fails this test, later on: afterGetStateit gets no buffer callbacks within the test's 3 s (STARTED0). It passes alone and in thehle::run above; the whole-lib run took 636 s under Rosetta, so I read it as the audio thread being late, not confirmed.mainand head (as reported in #258):bind::tests::create_list_reset_and_clear_state_track_initial_pso_on_d3d12,title_textures::tests::placed_title_textures_share_vram_and_preserve_pixels,vram::tests::d32s8_targets_take_their_own_size_of_video_memory.Tested by others (on head
76d2ff7)hle::xaudio2::tests pass, both lifetime tests run to completion (Opus through MSOpusDecoder). With the host's context cleared right after the call in a local build, the fallback returned the first submitted context for both codecs (0x1001 Opus, 0x3003 XMA2). https://github.com/ivall/xcl/pull/890#issuecomment-7125354697main7 passed / 2 failed (the XMA2 test andopus_source_voice_decodes_and_manages_lifetime, the sameGetStatecheck), head 9 / 0, 3 runs each. https://github.com/ivall/xcl/pull/890#issuecomment-7125561693main8 / 1, head 9 / 0, and head merged ontomain1ec4c98(no conflicts) 9 / 0, 3 runs each. https://github.com/ivall/xcl/pull/890#pullrequestreview-6035608448Regression run
scripts/smoke.ps1 -Seconds 60under PowerShell 7 on macOS, the retail title, release builds cross-built forx86_64-pc-windows-msvc, each from a clean tree of the commit, each on a fresh data root, one after the other. The script startsxcl.exethrough a small wrapper that runs it under Wine and rewrites only theLog:/Report:lines to macOS paths;XCL_DXC_THREADS=4for both runs. The blocks are as printed.maindoes not draw (OpenExistingHeapFromAddress … Not implemented, #258), so both runs sit at 0 frames for the 60 s and end cleanly; XCL's log has no XAudio2 line before that point, so the change is not reached. It is a check that nothing is worse (no crash, no device removal, the same frames), not a run of the change.gpu:is D3DMetal's adapter name, andpeak commitreads 0 MB under Wine, so the commit limit cannot be compared here. A Windows pair would say more.main:this PR:
Not tested
hle::xaudio2::tests ran on Windows, above); the GPU tests were not run for this PR.e2etest title's XAudio2 check (XMA2 GetState: ctx=0x0, queued=1under Wine, noted by @ClosetPie107).AI use
@ettehn on GitHub · 2026-11-24 07:46 UTC · original
Native Windows x64 verification on
76d2ff732e: all 9 XAudio2 unit tests passed with system XAudio2 2.9 (cargo test -p xcl --lib hle::xaudio2:: -- --test-threads=1 --nocapture). Both source-voice lifetime tests ran to completion, including the Opus path using Windows Media Foundation’s MSOpusDecoder. Neither took the missing-device/decoder skip.I also exercised the fallback separately. In a local test build I verified that the native GetState result had two queued buffers and a non-null current context, then cleared only that context immediately after the host call. The fallback returned the first submitted context for both codecs: 0x1001 for Opus and 0x3003 for XMA2. Both tests passed their subsequent playback callback and lifetime assertions. This second run simulates the missing host context on Windows; Wine and retail playback were outside this check.
OpenAI Codex (GPT-6.2 Astra) assisted with verification.
@ClosetPie107 on GitHub · 2026-11-24 07:57 UTC · original
Tested on Linux / RADV, and it also fixes the Opus variant of the same test.
Tested
experimental-11.0-20261112), vkd3d-proton v3.1 + #257's patch, DXVKv3.1.1-209, DXC 1.9.2609.5,opus.dll(libopus) from #257'sbuild-opus.shthroughXCL_OPUS_DIR.76d2ff7(basebeaa245) againstmain1ec4c98, both release builds forx86_64-pc-windows-gnu, Rust 1.96.0.xcl-<hash>.exe hle::xaudio2:: --test-threads=1under Wine, 3 runs each:main: 7 passed, 2 failed every run:xma2_source_voice_decodes_and_manages_lifetime(left: 0, right: 12291) andopus_source_voice_decodes_and_manages_lifetime(left: 0, right: 4097, the sameGetStatecontext check).Not tested: the whole suite on the head, the
e2etest title's XAudio2 check (XMA2 GetState: ctx=0x0, queued=1), and Windows.AI use: T3 Code (Claude Opus 5.5) built both, ran the tests and wrote this comment. The runs are real, on the hardware above, and I checked the report before posting.
mainreaches on Windows; the obstacle is replaced vtables — proposal: proxies #175@SlopTart on GitHub · 2026-11-24 09:34 UTC · original
Linux / AMD RDNA3 datapoint.
Merged state: head
76d2ff7onto main077ce40, clean merge.Full suite,
cargo test --workspace --release --no-fail-fast --target x86_64-pc-windows-gnu -- --test-threads=4: 707 passed, 9 failed, 41 ignored; failures are the known Wine-lane set from my #42 rows plus this rig's title-textures flake family (see #718). GetState oldest-buffer naming green.Not tested: retail titles (none here), Windows, RDNA4.
Counts only, no game data.
Machine: RX 7900 XT (RADV NAVI31), Mesa 26.2.5, kernel 7.2 (Arch), Proton Experimental (wine-11.0), patched vkd3d-proton v3.1, Rust cross
x86_64-pc-windows-gnu,XCL_NETWORK=0, release profile,--test-threads=4. My Linux rows: #42 / #718.AI use: Hermes agent (local Qwen-class) ran the suite and drafted this; I checked it before posting.
@vakaobr on GitHub · 2026-11-24 10:27 UTC · original
Test report from macOS (CrossOver/Wine), head
76d2ff7applied tomain9aec53d, with the cause on this host. Part of #258.Under CrossOver 26.3 (Wine 11.0),
GetStateon a source voice that has queued buffers but has not started returnspCurrentBufferContext = NULL. In upstream FAudio, 24.01 to 26.03 only name a buffer once it has started, and 26.04 namesqueued_buffers[0], as Windows does; Wine 11.0 bundles FAudio 25.12 (I did not check the FAudio inside the CrossOver binary). The XMA2 lifetime test'sleft: 0, right: 12291is that context (0x3003), not a sample count: the decode asserts before it pass. A temporary probe of the host's rawGetStateshowedctx=0x0 queued=2before Start and XCL's token after the firstOnBufferStart.Tested
x86_64-pc-windows-gnu(mingw-w64 GCC 16.2.0), debug.hle::xaudio2::tests, one per process (--exact <name> --test-threads=1), 3 runs each:main8 passed, 1 failed (xma2_source_voice_decodes_and_manages_lifetime), 0 ignored; with this PR 9 passed, 0 failed, 0 ignored.opus_source_voice_decodes_and_manages_lifetimereturns early in all runs ("MSOpusDecoder.dll not available"), so Opus under Wine is not covered here.max_by_keyinstead ofmin_by_keyin the fallback, the XMA2 test fails with0x4004(CTX_BAD).Not tested
AI use
@mikebuckets171 on GitHub · 2026-11-24 11:09 UTC · original
Verified on a second host, on the
gnullvmtarget: the failure reproduces on three differentmaincommits and on the Mac port branch, and your commit fixes it on today'smain.Host: MacBook Pro M5 Pro (48 GB), macOS 27.2.1, CrossOver 26 with D3DMetal, Rosetta 2, Rust 1.100.0,
x86_64-pc-windows-gnullvmwith LLVM-MinGW 20261117 (clang 23.1.6),--release --locked, test binaries under Wine, one test per process (--exact <full test path> --nocapture --test-threads=1), a fresh data root for each run.hle::xaudio2::tests::xma2_source_voice_decodes_and_manages_lifetime:1ec4c98(this PR's stated base)panicked at crates/xcl/src/hle/xaudio2.rs:1599:13: assertion left == right failed, left: 0, right: 12291, exit0x65beaa245(the base the description ran on)6efdabc(today's main)mac-on-main-wipdb065d8(the Mac port branch)6efdabc+ this PR's commit76d2ff7cherry-picked (clean, +16 / -2)0x0What the numbers are, since they read like a sample count and are not: the failing assert is
assert_eq!({ st.current_buffer_context } as usize, CTX_VALID)atxaudio2.rs:1599, withconst CTX_VALID: usize = 0x3003= 12291 - soleft: 0, right: 12291isGetState's current-buffer token, exactly as your description says. Everything before it passes on this host: both submits return S_OK,stats().xma_buffers_decodedis +1 andxma_decode_errors+1 (lines 1593-1594),buffers_queued == 2(1598). The assert sits beforestart(voice, 0, 0)at 1603, so what reads 0 is which bufferGetStatenames as current for a decoded voice with two buffers submitted and not yet started - not the XMA2 decode.Two things worth having on the record:
gnullvm/ LLVM-MinGW build here and on the clang-cl + xwin MSVC build the description used, and on the Mac port branch as well as on main - so the fix is not papering over a cross-build difference.6efdabcit applies cleanly (xaudio2.rs, +16 / -2, no conflicts) even though the PR's base is1ec4c98, and the PR reportsmergeable: true. So the pair above describesmaintoday against your change, not against a stale base.One methodological note, in case anyone else is about to run this pair: my first attempt at a "clean main" run looked like a pass, and it was a mistake of mine -
git checkout -- .restores the working tree from the index, so a staged cherry-pick stayed in the sources while HEAD still read as the base commit. Re-run in a worktree whose working tree was verified clean (I checked for the patch'sNEXT_BUFFER_SEQmarker in the file), and the base fails as above. Worth stating because "it passed here" would otherwise send someone down a dead end.Host: macOS 27.2.1 (Apple silicon, M5 Pro), CrossOver 26, D3DMetal; local inference unloaded and the bottle's wineserver stopped for each run. AI use: GPT-6 Luna built every tree, ran the tests and drafted this comment; the counts, line numbers and codes are from those runs.
@pablogonz12 on GitHub · 2026-11-24 18:48 UTC · original
Test report on RDNA4 / Wine:
76d2ff7merged ontomain9e3831e(clean merge). It fixes the XMA2 check of the e2e test title, and shows a second GetState gap that this change does not reach.Tested
x86_64-pc-windows-msvccross-built with cargo-xwin (static CRT), no Windows build.cargo test -p xcl --libbinary under Wine,--test-threads=4, with--skip jumps_to_outer_loop_heads_are_structured(it aborts the whole binary here, #1246): 722 passed, 4 failed, 21 ignored. The four:gpu_f64_roots,gpu_f64_math_random,gpu_nonfused_mad_and_mac_prevent_fma_contraction,gpu_depth_buffer_created_for_unordered_access_is_placed. None is XAudio2;hle::xaudio2alone: 9 passed.tests/e2e.rstest_title_runs_and_game_folder_is_untouched, run alone:main:[FAIL] XAudio2: ... XMA2 GetState: ctx=0x0, queued=1.[FAIL] XAudio2: ... Opus GetState: ctx=0x0, queued=1. The log of that run saysOpus: decoder = none (MSOpusDecoder.dll not available; no opus.dll ...)andOpus decoder unavailable ... falling back to silence. The voice is then not one of the decoded voices (it takes theXMAsilence path ofsubmit_source_buffer), soget_statehas no token to map and Wine returns a null context. Theget_statechange here only runs for voices inDECODED_VOICES. A host with libopus would take the decoded path; I did not run that.user32 ... not cloakedcheck (#1462 / #794), unrelated.Not tested
AI use
@shortside on GitHub · 2026-11-24 19:24 UTC · original
@pablogonz12 thanks, that is the run this PR was missing (the test title does not get that far on my Mac). The second gap is real and wider than the Opus voice: under Wine any voice XCL does not decode reads that way before it starts, a plain PCM voice too. It is in #1698, stacked on this one, so this commit and the runs against it stay as they are. If you have a moment, the test title's
Opus GetStatecheck on your host (Wine without libopus) is the one thing I cannot run for it.@crastinator on GitHub · 2026-11-24 19:25 UTC · original
@pablogonz12 matches what I see on RDNA2 under Wine (my review above, the Update section). The one case you didn't run, with libopus: given an
opus.dllfrom #257'sbuild-opus.sh(XCL_OPUS_DIR), the Opus voice takes the decoded path. The e2e test title's XAudio2 check then passes completely with this PR, andhle::xaudio2::is 9/9 withopus_source_voice_decodes_and_manages_lifetimeincluded (76d2ff7merged ontomain930e8b4, RX 6700 XT, Mesa 26.3.1, 3 runs). So what's left is only the silence fallback for an Opus voice when there's no decoder (stock Wine/Proton).@pablogonz12 on GitHub · 2026-11-24 22:41 UTC · original
On the merged
main689f2dbthe unit test this touches is red on AMD/RADV/Wine:hle::xaudio2::tests::xma2_source_voice_decodes_and_manages_lifetimefails atcrates/xcl/src/hle/xaudio2.rs:1599,GetStatereturnscurrent_buffer_context = 0where the test wants the playing buffer's0x3003, both in the full run and run alone (--exact). RX 9070 XT, RADV/Mesa 26.3.1, Wine GE-Proton11-14,x86_64-pc-windows-msvcrelease with+crt-static.At your head
76d2ff7the same test passes here (722 passed, 4 failed, 21 ignored, the four being the known ones), so the test that main carries today is green with this PR and red without it.Written with Claude (Anthropic) assistance; tested by me on the hardware listed.
@JJAutoCompare on GitHub · 2026-11-25 05:38 UTC · original
Empirical test report (
76d2ff73)Verified the clean, detached PR #890 head
76d2ff732e8af140a40570f7de38289a16861380.Hardware / environment
rustc 1.100.0 (0ef1bc386 2026-11-09)(x86_64-pc-windows-msvc), DXC1.9.2609.5 (01b62ad47), Cargo test profile with debug info and incremental compilation disabled.Invoke-ArcTest.ps1. No Arc GPU mutex was acquired. The focused tests use no D3D12 or GPU and require a working Windows XAudio2 output endpoint.Commands and results
cargo test --workspace --no-runexited 0 and built the workspace test executables.cargo test -p xcl --lib source_voice_decodes_and_manages_lifetime -- --nocaptureran withXCL_ADAPTER=NONE_CPU_ONLYandRUST_TEST_NOCAPTURE=1, and exited 0. Cargo reported 2 passed, 0 failed, 0 ignored and 691 filtered out. The log contained 0 uppercaseSKIPPEDmarkers and 2 explicitskipping: no audio devicemessages. Counting those early returns as skips gives 0 behavioral passes and 2 skipped.Observed behavior
The PR changes runtime code and adds or modifies no tests. The filter selected the existing XMA2 and Opus source-voice tests. Both created a system XAudio2 2.9 engine, then received
0x80070490fromCreateMasteringVoiceand returned before submitting buffers. The checks for two queued buffers and the oldest buffer's original context therefore did not run.Not tested
The full GPU workspace suite and game smoke runs were omitted. The XMA2 and Opus
GetStateassertions and the Wine/CrossOver null-context fallback remain unverified.AI use
Verified with T3 Code / Codex (gpt-6.2-sol, reasoningEffort: high). Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified counts against
pr890-focused.logand published.@DavidM1911 on GitHub · 2026-11-25 09:41 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)Thanks!
@shortside on GitHub · 2026-11-25 09:43 UTC · original
@pablogonz12 thanks for the run. The Opus case you hit behind this one is the gap #1698 covers (it is stacked on this PR); a run of that on your setup would be very welcome.
@pablogonz12 on GitHub · 2026-11-25 09:50 UTC · original
Ran the stacked head on Linux here.
e2ee5c0merged withmain568e7db(clean, no conflicts),cargo xwin test -p xcl --lib --release --target x86_64-pc-windows-msvc --target-dir target-static.--test-threads=4), filterxaudio2: 11 passed, 0 failed, 1115 filtered out.get_state_names_the_oldest_buffer_of_a_voice_that_is_not_decodedandxma2_source_voice_decodes_and_manages_lifetime. The run took the real path, not a skip:engine created (system XAudio2 2.9, flags 0x0)andXMA2 voice (1 ch., 48000 Hz) → real PCM16 decoding.main689f2dbalone (xma2GetState naming no context): with #890 + #1698 in the tree that assertion passes.Not tested: the full lib suite on this head, and any game run. Scope is the
xaudio2module. Written with Claude assistance.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.