XAudio2: GetState names the oldest queued buffer when the host gives none #890

Open
github-bot wants to merge 1 commit from github-bot/gh-890 into main AGit
Owner

@⁠shortside on GitHub · 2026-11-24 07:44 UTC · original
shortside:xaudio2/getstate-queued-context → main · +16 −2 · 1 files · 1 commits · open

Under Wine (CrossOver 26.3), GetState on a decoded (XMA / Opus) source voice that has buffers queued but has not started returns BuffersQueued = 2 and pCurrentBufferContext = NULL; Windows names the first queued buffer. hle::xaudio2::tests::xma2_source_voice_decodes_and_manages_lifetime checks 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, GetState now 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: DecodedBuffer gets a submission number (NEXT_BUFFER_SEQ); get_state falls back to the oldest live buffer when the host's current context is null and BuffersQueued != 0. +16 / -2, one commit.

Tested

  • MacBook Pro M5 Pro, macOS 27.2.1, Rosetta 2; CrossOver 26.3 (Wine 11.0), Windows 10 bottle, D3DMetal; DXC 1.9.2609. Cross-built for x86_64-pc-windows-msvc with 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; main is beaa245, 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: main 8 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 on main too): 278 passed, 3 failed, 2 ignored; this test passes. The 3 failures fail on main as well.
  • Whole lib, non-GPU (--skip ::gpu_ --test-threads=1, restarted past each crash), main vs 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_queue failed once on main and passed on reruns; vram::tests::d32s8_targets_take_their_own_size_of_video_memory crashed in the main run and not in the head's). In this whole-lib run the head still fails this test, later on: after GetState it gets no buffer callbacks within the test's 3 s (STARTED 0). It passes alone and in the hle:: run above; the whole-lib run took 636 s under Rosetta, so I read it as the audio thread being late, not confirmed.
  • Crashed on this host in both main and 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)

Regression run

  • From my Mac: MacBook Pro M5 Pro (24 GB), macOS 27.2.1, CrossOver 26.3 (Wine 11.0), D3DMetal. scripts/smoke.ps1 -Seconds 60 under PowerShell 7 on macOS, the retail title, release builds cross-built for x86_64-pc-windows-msvc, each from a clean tree of the commit, each on a fresh data root, one after the other. The script starts xcl.exe through a small wrapper that runs it under Wine and rewrites only the Log: / Report: lines to macOS paths; XCL_DXC_THREADS=4 for both runs. The blocks are as printed.
  • What they show and what they do not: on this host main does 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, and peak commit reads 0 MB under Wine, so the commit limit cannot be compared here. A Windows pair would say more.

main:

xcl-smoke v1
commit: b9b6ea62080cc62fc19e212033372d01c6214e5c
gpu: AMD Compatibility Mode
title: Retail game
seconds: 60
exit: 0x0
frames shown: 0 (PresentX 0)
presents per 2 s (last 3): 0 0 0
device removals: 0
crashes: 0
peak commit: 0 MB

this PR:

xcl-smoke v1
commit: 76d2ff732e8af140a40570f7de38289a16861380
gpu: AMD Compatibility Mode
title: Retail game
seconds: 60
exit: 0x0
frames shown: 0 (PresentX 0)
presents per 2 s (last 3): 0 0 0
device removals: 0
crashes: 0
peak commit: 0 MB

Not tested

  • The whole suite on Windows or a PC GPU (only the hle::xaudio2:: tests ran on Windows, above); the GPU tests were not run for this PR.
  • No retail title, no audible output.
  • The e2e test title's XAudio2 check (XMA2 GetState: ctx=0x0, queued=1 under Wine, noted by @⁠ClosetPie107).

AI use

  • Claude Code with Claude Opus 5.5: found the cause, wrote the change and this description, and ran the tests above on my machine.
**@⁠shortside** on GitHub · 2026-11-24 07:44 UTC · [original](https://github.com/xcl-dev/xcl/pull/890) `shortside:xaudio2/getstate-queued-context` → `main` · +16 −2 · 1 files · 1 commits · open Under Wine (CrossOver 26.3), `GetState` on a decoded (XMA / Opus) source voice that has buffers queued but has not started returns `BuffersQueued = 2` and `pCurrentBufferContext = NULL`; Windows names the first queued buffer. `hle::xaudio2::tests::xma2_source_voice_decodes_and_manages_lifetime` checks 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, `GetState` now 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`: `DecodedBuffer` gets a submission number (`NEXT_BUFFER_SEQ`); `get_state` falls back to the oldest live buffer when the host's current context is null and `BuffersQueued != 0`. +16 / -2, one commit. **Tested** - MacBook Pro M5 Pro, macOS 27.2.1, Rosetta 2; CrossOver 26.3 (Wine 11.0), Windows 10 bottle, D3DMetal; DXC 1.9.2609. Cross-built for `x86_64-pc-windows-msvc` with 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; `main` is `beaa245`, 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: `main` 8 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 on `main` too): 278 passed, 3 failed, 2 ignored; this test passes. The 3 failures fail on `main` as well. - Whole lib, non-GPU (`--skip ::gpu_ --test-threads=1`, restarted past each crash), `main` vs 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_queue` failed once on `main` and passed on reruns; `vram::tests::d32s8_targets_take_their_own_size_of_video_memory` crashed in the `main` run and not in the head's). In this whole-lib run the head still fails this test, later on: after `GetState` it gets no buffer callbacks within the test's 3 s (`STARTED` 0). It passes alone and in the `hle::` run above; the whole-lib run took 636 s under Rosetta, so I read it as the audio thread being late, not confirmed. - Crashed on this host in both `main` and 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`) - @⁠ettehn, native Windows x64, system XAudio2 2.9: all 9 `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-7125354697 - @⁠ClosetPie107, Linux, Proton Experimental's Wine, RX 9070 (RADV), with an Opus decoder: `main` 7 passed / 2 failed (the XMA2 test and `opus_source_voice_decodes_and_manages_lifetime`, the same `GetState` check), head 9 / 0, 3 runs each. https://github.com/ivall/xcl/pull/890#issuecomment-7125561693 - @⁠crastinator, Linux, Proton Experimental's Wine, RX 6700 XT (RADV): `main` 8 / 1, head 9 / 0, and head merged onto `main` `1ec4c98` (no conflicts) 9 / 0, 3 runs each. https://github.com/ivall/xcl/pull/890#pullrequestreview-6035608448 **Regression run** - From my Mac: MacBook Pro M5 Pro (24 GB), macOS 27.2.1, CrossOver 26.3 (Wine 11.0), D3DMetal. `scripts/smoke.ps1 -Seconds 60` under PowerShell 7 on macOS, the retail title, release builds cross-built for `x86_64-pc-windows-msvc`, each from a clean tree of the commit, each on a fresh data root, one after the other. The script starts `xcl.exe` through a small wrapper that runs it under Wine and rewrites only the `Log:` / `Report:` lines to macOS paths; `XCL_DXC_THREADS=4` for both runs. The blocks are as printed. - What they show and what they do not: on this host `main` does 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, and `peak commit` reads 0 MB under Wine, so the commit limit cannot be compared here. A Windows pair would say more. `main`: ``` xcl-smoke v1 commit: b9b6ea62080cc62fc19e212033372d01c6214e5c gpu: AMD Compatibility Mode title: Retail game seconds: 60 exit: 0x0 frames shown: 0 (PresentX 0) presents per 2 s (last 3): 0 0 0 device removals: 0 crashes: 0 peak commit: 0 MB ``` this PR: ``` xcl-smoke v1 commit: 76d2ff732e8af140a40570f7de38289a16861380 gpu: AMD Compatibility Mode title: Retail game seconds: 60 exit: 0x0 frames shown: 0 (PresentX 0) presents per 2 s (last 3): 0 0 0 device removals: 0 crashes: 0 peak commit: 0 MB ``` **Not tested** - The whole suite on Windows or a PC GPU (only the `hle::xaudio2::` tests ran on Windows, above); the GPU tests were not run for this PR. - No retail title, no audible output. - The `e2e` test title's XAudio2 check (`XMA2 GetState: ctx=0x0, queued=1` under Wine, noted by @⁠ClosetPie107). **AI use** - Claude Code with Claude Opus 5.5: found the cause, wrote the change and this description, and ran the tests above on my machine.
Under Wine (CrossOver 26.3), GetState on a decoded (XMA / Opus) source
voice that has buffers queued but has not started returns
BuffersQueued = 2 and pCurrentBufferContext = NULL. Windows names the
first queued buffer there, and xma2_source_voice_decodes_and_manages_lifetime
checks for it (left 0, right 0x3003).

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.
Each decoded buffer now carries its submission number, and GetState
names the oldest one that has not ended. When the host returns a context,
the mapping is unchanged, so Windows is not affected.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:35:47 +00:00
Author
Owner

@⁠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.

**@⁠ettehn** on GitHub · 2026-11-24 07:46 UTC · [original](https://github.com/xcl-dev/xcl/pull/890#issuecomment-7125354697) Native Windows x64 verification on 76d2ff732e8af140a40570f7de38289a16861380: 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.
Author
Owner

@⁠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

  • AMD Radeon RX 9070 (RADV GFX1201, Mesa 26.3.1), Ryzen 5 9600X, CachyOS, kernel 7.3.5. Proton Experimental's Wine (experimental-11.0-20261112), vkd3d-proton v3.1 + #257's patch, DXVK v3.1.1-209, DXC 1.9.2609.5, opus.dll (libopus) from #257's build-opus.sh through XCL_OPUS_DIR.
  • This PR's head 76d2ff7 (base beaa245) against main 1ec4c98, both release builds for x86_64-pc-windows-gnu, Rust 1.96.0.
  • xcl-<hash>.exe hle::xaudio2:: --test-threads=1 under Wine, 3 runs each:
    • main: 7 passed, 2 failed every run: xma2_source_voice_decodes_and_manages_lifetime (left: 0, right: 12291) and opus_source_voice_decodes_and_manages_lifetime (left: 0, right: 4097, the same GetState context check).
    • head: 9 passed, 0 failed every run.
  • The Opus test only reaches that check when an Opus decoder is there. That's probably why the description and the other Wine reports only name the XMA2 one.

Not tested: the whole suite on the head, the e2e test 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.

**@⁠ClosetPie107** on GitHub · 2026-11-24 07:57 UTC · [original](https://github.com/xcl-dev/xcl/pull/890#issuecomment-7125561693) Tested on Linux / RADV, and it also fixes the Opus variant of the same test. **Tested** - AMD Radeon RX 9070 (RADV GFX1201, Mesa 26.3.1), Ryzen 5 9600X, CachyOS, kernel 7.3.5. Proton Experimental's Wine (`experimental-11.0-20261112`), vkd3d-proton v3.1 + #257's patch, DXVK `v3.1.1-209`, DXC 1.9.2609.5, `opus.dll` (libopus) from #257's `build-opus.sh` through `XCL_OPUS_DIR`. - This PR's head `76d2ff7` (base `beaa245`) against `main` `1ec4c98`, both release builds for `x86_64-pc-windows-gnu`, Rust 1.96.0. - `xcl-<hash>.exe hle::xaudio2:: --test-threads=1` under Wine, 3 runs each: - `main`: **7 passed, 2 failed** every run: `xma2_source_voice_decodes_and_manages_lifetime` (`left: 0, right: 12291`) and `opus_source_voice_decodes_and_manages_lifetime` (`left: 0, right: 4097`, the same `GetState` context check). - head: **9 passed, 0 failed** every run. - The Opus test only reaches that check when an Opus decoder is there. That's probably why the description and the other Wine reports only name the XMA2 one. **Not tested:** the whole suite on the head, the `e2e` test 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.
Author
Owner

@⁠SlopTart on GitHub · 2026-11-24 09:34 UTC · original

Linux / AMD RDNA3 datapoint.

Merged state: head 76d2ff7 onto main 077ce40, 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.

**@⁠SlopTart** on GitHub · 2026-11-24 09:34 UTC · [original](https://github.com/xcl-dev/xcl/pull/890#issuecomment-7127594905) Linux / AMD RDNA3 datapoint. **Merged state:** head `76d2ff7` onto main `077ce40`, 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.
Author
Owner

@⁠vakaobr on GitHub · 2026-11-24 10:27 UTC · original

Test report from macOS (CrossOver/Wine), head 76d2ff7 applied to main 9aec53d, with the cause on this host. Part of #258.

Under CrossOver 26.3 (Wine 11.0), GetState on a source voice that has queued buffers but has not started returns pCurrentBufferContext = NULL. In upstream FAudio, 24.01 to 26.03 only name a buffer once it has started, and 26.04 names queued_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's left: 0, right: 12291 is that context (0x3003), not a sample count: the decode asserts before it pass. A temporary probe of the host's raw GetState showed ctx=0x0 queued=2 before Start and XCL's token after the first OnBufferStart.

Tested

  • MacBook Pro M5 Pro, macOS 27.2.1, Rosetta 2, CrossOver 26.3.0.39832; Rust 1.100.0, x86_64-pc-windows-gnu (mingw-w64 GCC 16.2.0), debug.
  • The 9 hle::xaudio2:: tests, one per process (--exact <name> --test-threads=1), 3 runs each: main 8 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_lifetime returns early in all runs ("MSOpusDecoder.dll not available"), so Opus under Wine is not covered here.
  • Mutation: with max_by_key instead of min_by_key in the fallback, the XMA2 test fails with 0x4004 (CTX_BAD).

Not tested

  • Windows, the whole suite, GPU tests, Opus under Wine, plain PCM voices (the fallback covers decoded voices only), any title.

AI use

  • Claude Code with Claude Opus 5.5 found the cause, added and removed the probe, ran the tests above on this machine and wrote this report.
**@⁠vakaobr** on GitHub · 2026-11-24 10:27 UTC · [original](https://github.com/xcl-dev/xcl/pull/890#issuecomment-7128813485) Test report from macOS (CrossOver/Wine), head `76d2ff7` applied to `main` `9aec53d`, with the cause on this host. Part of #258. Under CrossOver 26.3 (Wine 11.0), `GetState` on a source voice that has queued buffers but has not started returns `pCurrentBufferContext = NULL`. In upstream FAudio, 24.01 to 26.03 only name a buffer once it has started, and 26.04 names `queued_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's `left: 0, right: 12291` is that context (`0x3003`), not a sample count: the decode asserts before it pass. A temporary probe of the host's raw `GetState` showed `ctx=0x0 queued=2` before Start and XCL's token after the first `OnBufferStart`. **Tested** - MacBook Pro M5 Pro, macOS 27.2.1, Rosetta 2, CrossOver 26.3.0.39832; Rust 1.100.0, `x86_64-pc-windows-gnu` (mingw-w64 GCC 16.2.0), debug. - The 9 `hle::xaudio2::` tests, one per process (`--exact <name> --test-threads=1`), 3 runs each: `main` 8 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_lifetime` returns early in all runs ("MSOpusDecoder.dll not available"), so Opus under Wine is not covered here. - Mutation: with `max_by_key` instead of `min_by_key` in the fallback, the XMA2 test fails with `0x4004` (`CTX_BAD`). **Not tested** - Windows, the whole suite, GPU tests, Opus under Wine, plain PCM voices (the fallback covers decoded voices only), any title. **AI use** - Claude Code with Claude Opus 5.5 found the cause, added and removed the probe, ran the tests above on this machine and wrote this report.
Author
Owner

@⁠mikebuckets171 on GitHub · 2026-11-24 11:09 UTC · original

Verified on a second host, on the gnullvm target: the failure reproduces on three different main commits and on the Mac port branch, and your commit fixes it on today's main.

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-gnullvm with 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:

tree result
1ec4c98 (this PR's stated base) FAILED 2/2 - panicked at crates/xcl/src/hle/xaudio2.rs:1599:13: assertion left == right failed, left: 0, right: 12291, exit 0x65
beaa245 (the base the description ran on) FAILED 2/2 - identical
6efdabc (today's main) FAILED 3/3 - identical
mac-on-main-wip db065d8 (the Mac port branch) FAILED 2/2 - identical
6efdabc + this PR's commit 76d2ff7 cherry-picked (clean, +16 / -2) ok 4/4, 0.29-0.32 s each, exit 0x0

What 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) at xaudio2.rs:1599, with const CTX_VALID: usize = 0x3003 = 12291 - so left: 0, right: 12291 is GetState's current-buffer token, exactly as your description says. Everything before it passes on this host: both submits return S_OK, stats().xma_buffers_decoded is +1 and xma_decode_errors +1 (lines 1593-1594), buffers_queued == 2 (1598). The assert sits before start(voice, 0, 0) at 1603, so what reads 0 is which buffer GetState names 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:

  • Not a toolchain artifact. The same failure appears on the 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.
  • The commit still applies to current main. Cherry-picked onto 6efdabc it applies cleanly (xaudio2.rs, +16 / -2, no conflicts) even though the PR's base is 1ec4c98, and the PR reports mergeable: true. So the pair above describes main today 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's NEXT_BUFFER_SEQ marker 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.

**@⁠mikebuckets171** on GitHub · 2026-11-24 11:09 UTC · [original](https://github.com/xcl-dev/xcl/pull/890#issuecomment-7129739382) **Verified on a second host, on the `gnullvm` target: the failure reproduces on three different `main` commits and on the Mac port branch, and your commit fixes it on today's `main`.** 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-gnullvm` with 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`: | tree | result | |---|---| | `1ec4c98` (this PR's stated base) | **FAILED** 2/2 - `panicked at crates/xcl/src/hle/xaudio2.rs:1599:13: assertion left == right failed, left: 0, right: 12291`, exit `0x65` | | `beaa245` (the base the description ran on) | **FAILED** 2/2 - identical | | `6efdabc` (today's main) | **FAILED** 3/3 - identical | | `mac-on-main-wip` `db065d8` (the Mac port branch) | **FAILED** 2/2 - identical | | `6efdabc` + this PR's commit `76d2ff7` cherry-picked (clean, +16 / -2) | **ok** 4/4, 0.29-0.32 s each, exit `0x0` | **What 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)` at `xaudio2.rs:1599`, with `const CTX_VALID: usize = 0x3003` = 12291 - so `left: 0, right: 12291` is `GetState`'s current-buffer token, exactly as your description says. Everything before it passes on this host: both submits return S_OK, `stats().xma_buffers_decoded` is +1 and `xma_decode_errors` +1 (lines 1593-1594), `buffers_queued == 2` (1598). The assert sits *before* `start(voice, 0, 0)` at 1603, so what reads 0 is which buffer `GetState` names 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: - **Not a toolchain artifact.** The same failure appears on the `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. - **The commit still applies to current main.** Cherry-picked onto `6efdabc` it applies cleanly (`xaudio2.rs`, +16 / -2, no conflicts) even though the PR's base is `1ec4c98`, and the PR reports `mergeable: true`. So the pair above describes `main` today 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's `NEXT_BUFFER_SEQ` marker 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.
Author
Owner

@⁠pablogonz12 on GitHub · 2026-11-24 18:48 UTC · original

Test report on RDNA4 / Wine: 76d2ff7 merged onto main 9e3831e (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

  • AMD Radeon RX 9070 XT (RADV, Mesa 26.3.1), Ryzen 9 9900X, CachyOS; Wine GE-Proton11-14, vkd3d-proton v3.1, DXC 1.9.2609.5; release, x86_64-pc-windows-msvc cross-built with cargo-xwin (static CRT), no Windows build.
  • cargo test -p xcl --lib binary 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::xaudio2 alone: 9 passed.
  • tests/e2e.rs test_title_runs_and_game_folder_is_untouched, run alone:
    • main: [FAIL] XAudio2: ... XMA2 GetState: ctx=0x0, queued=1.
    • with this PR: the XMA2 check passes; the next check fails: [FAIL] XAudio2: ... Opus GetState: ctx=0x0, queued=1. The log of that run says Opus: decoder = none (MSOpusDecoder.dll not available; no opus.dll ...) and Opus decoder unavailable ... falling back to silence. The voice is then not one of the decoded voices (it takes the XMA silence path of submit_source_buffer), so get_state has no token to map and Wine returns a null context. The get_state change here only runs for voices in DECODED_VOICES. A host with libopus would take the decoded path; I did not run that.
    • The same run also fails the user32 ... not cloaked check (#1462 / #794), unrelated.

Not tested

  • Windows; Wine with libopus available; the retail title.

AI use

  • Written with Claude (Anthropic) assistance; run by me on the hardware above.
**@⁠pablogonz12** on GitHub · 2026-11-24 18:48 UTC · [original](https://github.com/xcl-dev/xcl/pull/890#issuecomment-7141184763) Test report on RDNA4 / Wine: `76d2ff7` merged onto `main` `9e3831e` (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** - AMD Radeon RX 9070 XT (RADV, Mesa 26.3.1), Ryzen 9 9900X, CachyOS; Wine GE-Proton11-14, vkd3d-proton v3.1, DXC 1.9.2609.5; release, `x86_64-pc-windows-msvc` cross-built with cargo-xwin (static CRT), no Windows build. - `cargo test -p xcl --lib` binary 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::xaudio2` alone: 9 passed. - `tests/e2e.rs` `test_title_runs_and_game_folder_is_untouched`, run alone: - `main`: `[FAIL] XAudio2: ... XMA2 GetState: ctx=0x0, queued=1`. - with this PR: the XMA2 check passes; the next check fails: `[FAIL] XAudio2: ... Opus GetState: ctx=0x0, queued=1`. The log of that run says `Opus: decoder = none (MSOpusDecoder.dll not available; no opus.dll ...)` and `Opus decoder unavailable ... falling back to silence`. The voice is then not one of the decoded voices (it takes the `XMA` silence path of `submit_source_buffer`), so `get_state` has no token to map and Wine returns a null context. The `get_state` change here only runs for voices in `DECODED_VOICES`. A host with libopus would take the decoded path; I did not run that. - The same run also fails the `user32 ... not cloaked` check (#1462 / #794), unrelated. **Not tested** - Windows; Wine with libopus available; the retail title. **AI use** - Written with Claude (Anthropic) assistance; run by me on the hardware above.
Author
Owner

@⁠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 GetState check on your host (Wine without libopus) is the one thing I cannot run for it.

**@⁠shortside** on GitHub · 2026-11-24 19:24 UTC · [original](https://github.com/xcl-dev/xcl/pull/890#issuecomment-7142043378) @⁠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 GetState` check on your host (Wine without libopus) is the one thing I cannot run for it.
Author
Owner

@⁠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.dll from #257's build-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, and hle::xaudio2:: is 9/9 with opus_source_voice_decodes_and_manages_lifetime included (76d2ff7 merged onto main 930e8b4, 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).

**@⁠crastinator** on GitHub · 2026-11-24 19:25 UTC · [original](https://github.com/xcl-dev/xcl/pull/890#issuecomment-7142073313) @⁠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.dll` from #257's `build-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, and `hle::xaudio2::` is 9/9 with `opus_source_voice_decodes_and_manages_lifetime` included (`76d2ff7` merged onto `main` `930e8b4`, 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).
Author
Owner

@⁠pablogonz12 on GitHub · 2026-11-24 22:41 UTC · original

On the merged main 689f2db the unit test this touches is red on AMD/RADV/Wine: hle::xaudio2::tests::xma2_source_voice_decodes_and_manages_lifetime fails at crates/xcl/src/hle/xaudio2.rs:1599, GetState returns current_buffer_context = 0 where the test wants the playing buffer's 0x3003, 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-msvc release with +crt-static.

At your head 76d2ff7 the 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.

**@⁠pablogonz12** on GitHub · 2026-11-24 22:41 UTC · [original](https://github.com/xcl-dev/xcl/pull/890#issuecomment-7146530057) On the merged `main` `689f2db` the unit test this touches is red on AMD/RADV/Wine: `hle::xaudio2::tests::xma2_source_voice_decodes_and_manages_lifetime` fails at `crates/xcl/src/hle/xaudio2.rs:1599`, `GetState` returns `current_buffer_context = 0` where the test wants the playing buffer's `0x3003`, 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-msvc` release with `+crt-static`. At your head `76d2ff7` the 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.
Author
Owner

@⁠JJAutoCompare on GitHub · 2026-11-25 05:38 UTC · original

Empirical test report (76d2ff73)

Verified the clean, detached PR #890 head 76d2ff732e8af140a40570f7de38289a16861380.

Hardware / environment

  • STOR-WINLAB, Windows x64 build 26200, AuthenticAMD Family 23 Model 113 Stepping 0.
  • rustc 1.100.0 (0ef1bc386 2026-11-09) (x86_64-pc-windows-msvc), DXC 1.9.2609.5 (01b62ad47), Cargo test profile with debug info and incremental compilation disabled.
  • Both commands ran directly in PowerShell outside 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-run exited 0 and built the workspace test executables.
  • cargo test -p xcl --lib source_voice_decodes_and_manages_lifetime -- --nocapture ran with XCL_ADAPTER=NONE_CPU_ONLY and RUST_TEST_NOCAPTURE=1, and exited 0. Cargo reported 2 passed, 0 failed, 0 ignored and 691 filtered out. The log contained 0 uppercase SKIPPED markers and 2 explicit skipping: no audio device messages. 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 0x80070490 from CreateMasteringVoice and 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 GetState assertions 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.log and published.

**@⁠JJAutoCompare** on GitHub · 2026-11-25 05:38 UTC · [original](https://github.com/xcl-dev/xcl/pull/890#issuecomment-7153994808) ### Empirical test report (76d2ff73) Verified the clean, detached PR #890 head `76d2ff732e8af140a40570f7de38289a16861380`. **Hardware / environment** - STOR-WINLAB, Windows x64 build 26200, AuthenticAMD Family 23 Model 113 Stepping 0. - `rustc 1.100.0 (0ef1bc386 2026-11-09)` (`x86_64-pc-windows-msvc`), DXC `1.9.2609.5 (01b62ad47)`, Cargo test profile with debug info and incremental compilation disabled. - Both commands ran directly in PowerShell outside `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-run` exited 0 and built the workspace test executables. - `cargo test -p xcl --lib source_voice_decodes_and_manages_lifetime -- --nocapture` ran with `XCL_ADAPTER=NONE_CPU_ONLY` and `RUST_TEST_NOCAPTURE=1`, and exited 0. Cargo reported 2 passed, 0 failed, 0 ignored and 691 filtered out. The log contained 0 uppercase `SKIPPED` markers and 2 explicit `skipping: no audio device` messages. 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 `0x80070490` from `CreateMasteringVoice` and 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 `GetState` assertions 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.log` and published.
Author
Owner

@⁠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!

**@⁠DavidM1911** on GitHub · 2026-11-25 09:41 UTC · [original](https://github.com/xcl-dev/xcl/pull/890#issuecomment-7158682471) 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!
Author
Owner

@⁠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.

**@⁠shortside** on GitHub · 2026-11-25 09:43 UTC · [original](https://github.com/xcl-dev/xcl/pull/890#issuecomment-7158724154) @⁠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.
Author
Owner

@⁠pablogonz12 on GitHub · 2026-11-25 09:50 UTC · original

Ran the stacked head on Linux here.

  • #1698 e2ee5c0 merged with main 568e7db (clean, no conflicts), cargo xwin test -p xcl --lib --release --target x86_64-pc-windows-msvc --target-dir target-static.
  • Under Wine GE-Proton11-14 (RX 9070 XT / RDNA4, RADV, Mesa 26.3.1, Windows-msvc build, --test-threads=4), filter xaudio2: 11 passed, 0 failed, 1115 filtered out.
  • That includes get_state_names_the_oldest_buffer_of_a_voice_that_is_not_decoded and xma2_source_voice_decodes_and_manages_lifetime. The run took the real path, not a skip: engine created (system XAudio2 2.9, flags 0x0) and XMA2 voice (1 ch., 48000 Hz) → real PCM16 decoding.
  • Consistent with the earlier red we saw on main 689f2db alone (xma2 GetState 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 xaudio2 module. Written with Claude assistance.

**@⁠pablogonz12** on GitHub · 2026-11-25 09:50 UTC · [original](https://github.com/xcl-dev/xcl/pull/890#issuecomment-7158878199) Ran the stacked head on Linux here. - #1698 `e2ee5c0` merged with `main` `568e7db` (clean, no conflicts), `cargo xwin test -p xcl --lib --release --target x86_64-pc-windows-msvc --target-dir target-static`. - Under Wine GE-Proton11-14 (RX 9070 XT / RDNA4, RADV, Mesa 26.3.1, Windows-msvc build, `--test-threads=4`), filter `xaudio2`: **11 passed, 0 failed, 1115 filtered out**. - That includes `get_state_names_the_oldest_buffer_of_a_voice_that_is_not_decoded` and `xma2_source_voice_decodes_and_manages_lifetime`. The run took the real path, not a skip: `engine created (system XAudio2 2.9, flags 0x0)` and `XMA2 voice (1 ch., 48000 Hz) → real PCM16 decoding`. - Consistent with the earlier red we saw on `main` `689f2db` alone (`xma2` GetState 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 `xaudio2` module. Written with Claude assistance.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/890/head:github-bot/gh-890'
git switch 'github-bot/gh-890'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-890'
git switch 'github-bot/gh-890'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-890'
git switch 'github-bot/gh-890'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-890'
git switch 'main'
git merge --squash 'github-bot/gh-890'
git switch 'main'
git merge --ff-only 'github-bot/gh-890'
git switch 'main'
git merge 'github-bot/gh-890'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.