XAudio2: under Wine GetState names the oldest queued buffer of a voice XCL does not decode #1698

Open
github-bot wants to merge 2 commits from github-bot/gh-1698 into main AGit
Owner

@⁠shortside on GitHub · 2026-11-24 19:23 UTC · original
shortside:xaudio2/getstate-undecoded-voices → main · +209 −5 · 1 files · 2 commits · open

Stacked on #890; only the top commit (e2ee5c0) belongs here.

#890 makes GetState name the oldest queued buffer of a decoded voice when the host names none. @⁠pablogonz12's run of it (#890) showed the same gap one check further in the test title: Opus GetState: ctx=0x0, queued=1 under Wine without libopus, where the voice plays silence and is not a decoded one. It is wider than that: under Wine any source voice XCL does not decode reads so before it starts, a plain PCM voice too (two buffers queued: 2 queued, context 0, on CrossOver 26.3).

Under Wine only, XCL now keeps the contexts submitted to such a voice (at most the 64 a voice can hold) and answers a null current context with buffers queued from them. On Windows nothing is kept and nothing is asked: the host answers.

What is in it (crates/xcl/src/hle/xaudio2.rs, +193 / -3 with the tests)

  • QUEUED: voice → the contexts submitted, oldest first; note_submitted, oldest_queued (the host's queued buffers are the last ones submitted, so with N queued it is the N-th from the end), note_flushed (a flush keeps the playing buffer, the oldest of those queued).
  • submit_source_buffer: on the path that is not decoded (PCM passed through, or silence), a submit the host took is noted. flush_source_buffers: asks the host its queue before and after. destroy_voice: drops the record. All three only with util::under_wine().
  • get_state: after the decoded voices' branch (unchanged in what it does; it now returns), a null context with buffers queued is answered from QUEUED.
  • Tests: queued_contexts_follow_submits_and_flushes (the record alone, any host) and get_state_names_the_oldest_buffer_of_a_voice_that_is_not_decoded (a PCM voice on the real engine: two queued and not started names the first; after they have played, a third names itself).

Tested

  • MacBook Pro M5 Pro, macOS 27.2.1, Rosetta 2; CrossOver 26.3 (Wine 11.0), Windows 10 bottle; Rust 1.100.0, cross-built for x86_64-pc-windows-msvc with clang-cl / lld-link 23.1.6 and an xwin SDK 10.0.26100, debug. The lib test binary run under Wine. Base main c160d86 + #890's commit.
  • hle::xaudio2:: --test-threads=1, 3 runs at the head: 11 passed, 0 failed every run.
  • The engine test with the QUEUED answer in get_state switched off (a local edit, reverted), 2 runs: failed, left: (2, 0), right: (2, 20481) ("two queued, not started"; 20481 is the context 0x5001). With it on: passed. So the test fails without the change on this host.

Tested by others

  • @⁠pablogonz12, on Linux under Wine GE-Proton11-14 (RX 9070 XT, RADV, Mesa 26.3.1), this head e2ee5c0 merged with main 568e7db: the xaudio2 tests, 11 passed, 0 failed, on the real engine (system XAudio2 2.9), including get_state_names_the_oldest_buffer_of_a_voice_that_is_not_decoded. This is the Opus case he met behind #890. #890
  • @⁠DavidM1911, on Windows 11 with an RTX 3060 Ti, the branch merged with main: cargo test -p xcl --lib, all passed, 0 failed. #1698

Regression run

  • From @⁠papasmurph0, on Windows 11 with an RTX 4080 SUPER, the retail title of #505, 60 s, both blocks as posted in #1698 (on Windows the change is not switched on, so this is the regression check; no Mac pair with a title yet):

main:

xcl-smoke v1
commit: 85e38262ff94aecd75d6f83fa8156a8b7697bd13
gpu: NVIDIA GeForce RTX 4080 SUPER
title: t1
seconds: 60
exit: 0x0
frames shown: 1333 (PresentX 1333)
presents per 2 s (last 3): 11 21 49
device removals: 0
crashes: 0
peak commit: 25722 MB

this PR:

xcl-smoke v1
commit: e2ee5c0fc24ffa9d5cf9d27bfcfe7f5408460d3a
gpu: NVIDIA GeForce RTX 4080 SUPER
title: t1
seconds: 60
exit: 0x0
frames shown: 1235 (PresentX 1235)
presents per 2 s (last 3): 44 47 60
device removals: 0
crashes: 0
peak commit: 27346 MB

Not tested

  • The test title's Opus GetState check itself: main does not get that far on this host (D3DMetal). The silent voice goes through the same branch of submit_source_buffer as the PCM voice tested here; a Wine host without libopus that runs the title can confirm it.
  • Windows: not run by me; the library tests were run there by @⁠DavidM1911 (above). On Windows the engine test passes without the new path too (the host names the buffer), so that run does not exercise it.
  • The whole suite, GPU tests, any title.
  • A flush the host carries out later than the call: covered in the record's test (the last N submitted are still the right ones), not on a real engine.

AI use

  • Claude Code with Claude Fable 5.2: found the wider case, wrote the change, the tests and this description, and ran the tests above on my machine.

🤖 Generated with Claude Code

**@⁠shortside** on GitHub · 2026-11-24 19:23 UTC · [original](https://github.com/xcl-dev/xcl/pull/1698) `shortside:xaudio2/getstate-undecoded-voices` → `main` · +209 −5 · 1 files · 2 commits · open Stacked on #890; only the top commit (`e2ee5c0`) belongs here. #890 makes `GetState` name the oldest queued buffer of a **decoded** voice when the host names none. @⁠pablogonz12's run of it (https://git.gtahub.st/github/xcl-dev--xcl/pulls/890) showed the same gap one check further in the test title: `Opus GetState: ctx=0x0, queued=1` under Wine without libopus, where the voice plays silence and is not a decoded one. It is wider than that: under Wine any source voice XCL does not decode reads so before it starts, a plain PCM voice too (two buffers queued: 2 queued, context 0, on CrossOver 26.3). Under Wine only, XCL now keeps the contexts submitted to such a voice (at most the 64 a voice can hold) and answers a null current context with buffers queued from them. On Windows nothing is kept and nothing is asked: the host answers. **What is in it** (`crates/xcl/src/hle/xaudio2.rs`, +193 / -3 with the tests) - `QUEUED`: voice → the contexts submitted, oldest first; `note_submitted`, `oldest_queued` (the host's queued buffers are the last ones submitted, so with N queued it is the N-th from the end), `note_flushed` (a flush keeps the playing buffer, the oldest of those queued). - `submit_source_buffer`: on the path that is not decoded (PCM passed through, or silence), a submit the host took is noted. `flush_source_buffers`: asks the host its queue before and after. `destroy_voice`: drops the record. All three only with `util::under_wine()`. - `get_state`: after the decoded voices' branch (unchanged in what it does; it now returns), a null context with buffers queued is answered from `QUEUED`. - Tests: `queued_contexts_follow_submits_and_flushes` (the record alone, any host) and `get_state_names_the_oldest_buffer_of_a_voice_that_is_not_decoded` (a PCM voice on the real engine: two queued and not started names the first; after they have played, a third names itself). **Tested** - MacBook Pro M5 Pro, macOS 27.2.1, Rosetta 2; CrossOver 26.3 (Wine 11.0), Windows 10 bottle; Rust 1.100.0, cross-built for `x86_64-pc-windows-msvc` with clang-cl / lld-link 23.1.6 and an xwin SDK 10.0.26100, debug. The lib test binary run under Wine. Base `main` `c160d86` + #890's commit. - `hle::xaudio2:: --test-threads=1`, 3 runs at the head: 11 passed, 0 failed every run. - The engine test with the `QUEUED` answer in `get_state` switched off (a local edit, reverted), 2 runs: failed, `left: (2, 0), right: (2, 20481)` ("two queued, not started"; 20481 is the context `0x5001`). With it on: passed. So the test fails without the change on this host. **Tested by others** - @⁠pablogonz12, on Linux under Wine GE-Proton11-14 (RX 9070 XT, RADV, Mesa 26.3.1), this head `e2ee5c0` merged with `main` `568e7db`: the `xaudio2` tests, 11 passed, 0 failed, on the real engine (`system XAudio2 2.9`), including `get_state_names_the_oldest_buffer_of_a_voice_that_is_not_decoded`. This is the Opus case he met behind #890. https://git.gtahub.st/github/xcl-dev--xcl/pulls/890 - @⁠DavidM1911, on Windows 11 with an RTX 3060 Ti, the branch merged with `main`: `cargo test -p xcl --lib`, all passed, 0 failed. https://git.gtahub.st/github/xcl-dev--xcl/pulls/1698 **Regression run** - From @⁠papasmurph0, on Windows 11 with an RTX 4080 SUPER, the retail title of #505, 60 s, both blocks as posted in https://git.gtahub.st/github/xcl-dev--xcl/pulls/1698 (on Windows the change is not switched on, so this is the regression check; no Mac pair with a title yet): `main`: ``` xcl-smoke v1 commit: 85e38262ff94aecd75d6f83fa8156a8b7697bd13 gpu: NVIDIA GeForce RTX 4080 SUPER title: t1 seconds: 60 exit: 0x0 frames shown: 1333 (PresentX 1333) presents per 2 s (last 3): 11 21 49 device removals: 0 crashes: 0 peak commit: 25722 MB ``` this PR: ``` xcl-smoke v1 commit: e2ee5c0fc24ffa9d5cf9d27bfcfe7f5408460d3a gpu: NVIDIA GeForce RTX 4080 SUPER title: t1 seconds: 60 exit: 0x0 frames shown: 1235 (PresentX 1235) presents per 2 s (last 3): 44 47 60 device removals: 0 crashes: 0 peak commit: 27346 MB ``` **Not tested** - The test title's `Opus GetState` check itself: `main` does not get that far on this host (D3DMetal). The silent voice goes through the same branch of `submit_source_buffer` as the PCM voice tested here; a Wine host without libopus that runs the title can confirm it. - Windows: not run by me; the library tests were run there by @⁠DavidM1911 (above). On Windows the engine test passes without the new path too (the host names the buffer), so that run does not exercise it. - The whole suite, GPU tests, any title. - A flush the host carries out later than the call: covered in the record's test (the last N submitted are still the right ones), not on a real engine. **AI use** - Claude Code with Claude Fable 5.2: found the wider case, wrote the change, the tests and this description, and ran the tests above on my machine. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
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]>
Wine's XAudio2 counts the buffers of a source voice that has not started
but names no current one, where Windows names the first queued buffer.
The change before this one answers that for decoded (XMA / Opus) voices
from their own record. A voice XCL does not decode has none: plain PCM,
and the silence that stands in for XMA / Opus without a decoder (the test
title's "Opus GetState: ctx=0x0, queued=1" under Wine without libopus). A
PCM voice with two buffers queued reads (2 queued, context 0) under
CrossOver 26.3.

Under Wine only, the contexts submitted to such a voice are kept, oldest
first and at most the 64 a voice can hold; the host's queued buffers are
the last ones submitted, so a null current context with N queued is the
N-th from the end. FlushSourceBuffers keeps what the host kept, and
DestroyVoice drops the record. On Windows nothing is kept and nothing is
asked: the host answers.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:02:01 +00:00
Author
Owner

@⁠papasmurph0 on GitHub · 2026-11-24 20:08 UTC · original

Regression run for this PR on Windows / NVIDIA, since it has no xcl-smoke pair yet.

Tested

  • NVIDIA GeForce RTX 4080 SUPER (driver 32.0.16.1088), Ryzen 7 7800X3D, 64 GB RAM, Windows 11 build 26200, rustc 1.100.0 MSVC, release; scripts/smoke.ps1 -Seconds 60 on the retail title of #505 (game folder passed as a neutral junction, hence title: t1), each build from a clean worktree of the exact commit.

main:

xcl-smoke v1
commit: 85e38262ff94aecd75d6f83fa8156a8b7697bd13
gpu: NVIDIA GeForce RTX 4080 SUPER
title: t1
seconds: 60
exit: 0x0
frames shown: 1333 (PresentX 1333)
presents per 2 s (last 3): 11 21 49
device removals: 0
crashes: 0
peak commit: 25722 MB

this PR:

xcl-smoke v1
commit: e2ee5c0fc24ffa9d5cf9d27bfcfe7f5408460d3a
gpu: NVIDIA GeForce RTX 4080 SUPER
title: t1
seconds: 60
exit: 0x0
frames shown: 1235 (PresentX 1235)
presents per 2 s (last 3): 44 47 60
device removals: 0
crashes: 0
peak commit: 27346 MB

Both runs started from the same state (the title's settings already saved, so no first-run screens). The PR's run is within the limits: 93 % of main's frames, 106 % of its peak commit, no crash, no device removal. A first run of this PR right after the title had saved its settings, paired with a main run that still showed the first-run screens, is left out: the two did not start from the same state.

Not tested: Wine; on native Windows the host's XAudio2 names its buffers, so the PR's branch is not reached and this is a regression check only.

AI use: Claude Code (Claude Opus 5.5) built the trees, made the runs on my PC and wrote this report; I asked for it to be posted.

**@⁠papasmurph0** on GitHub · 2026-11-24 20:08 UTC · [original](https://github.com/xcl-dev/xcl/pull/1698#issuecomment-7143103427) Regression run for this PR on Windows / NVIDIA, since it has no `xcl-smoke` pair yet. **Tested** - NVIDIA GeForce RTX 4080 SUPER (driver 32.0.16.1088), Ryzen 7 7800X3D, 64 GB RAM, Windows 11 build 26200, rustc 1.100.0 MSVC, release; `scripts/smoke.ps1 -Seconds 60` on the retail title of #505 (game folder passed as a neutral junction, hence `title: t1`), each build from a clean worktree of the exact commit. `main`: ``` xcl-smoke v1 commit: 85e38262ff94aecd75d6f83fa8156a8b7697bd13 gpu: NVIDIA GeForce RTX 4080 SUPER title: t1 seconds: 60 exit: 0x0 frames shown: 1333 (PresentX 1333) presents per 2 s (last 3): 11 21 49 device removals: 0 crashes: 0 peak commit: 25722 MB ``` this PR: ``` xcl-smoke v1 commit: e2ee5c0fc24ffa9d5cf9d27bfcfe7f5408460d3a gpu: NVIDIA GeForce RTX 4080 SUPER title: t1 seconds: 60 exit: 0x0 frames shown: 1235 (PresentX 1235) presents per 2 s (last 3): 44 47 60 device removals: 0 crashes: 0 peak commit: 27346 MB ``` Both runs started from the same state (the title's settings already saved, so no first-run screens). The PR's run is within the limits: 93 % of `main`'s frames, 106 % of its peak commit, no crash, no device removal. A first run of this PR right after the title had saved its settings, paired with a `main` run that still showed the first-run screens, is left out: the two did not start from the same state. **Not tested:** Wine; on native Windows the host's XAudio2 names its buffers, so the PR's branch is not reached and this is a regression check only. AI use: Claude Code (Claude Opus 5.5) built the trees, made the runs on my PC and wrote this report; I asked for it to be posted.
Author
Owner

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

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, ~23 ignored.

Thanks!

**@⁠DavidM1911** on GitHub · 2026-11-24 22:09 UTC · [original](https://github.com/xcl-dev/xcl/pull/1698#issuecomment-7145882134) Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~23 ignored. Thanks!
Author
Owner

@⁠vakaobr on GitHub · 2026-11-25 16:15 UTC · original

Tested e2ee5c0 on a Mac: the test title's Opus check passes with it.

Tested (MacBook Pro M5 Pro, macOS 27.2.1, CrossOver 26.3.0, D3DMetal 3.0, no libopus, Rust 1.100.0 x86_64-pc-windows-gnu, debug). Cherry-picked onto the Mac branch from #258 (vakaobr/xcl mac/integration, which already has #890's commit through mac7, plus #750 so the title gets that far), not onto main.

  • e2e::test_title_runs_and_game_folder_is_untouched: without it, XAudio2 … Opus GetState: ctx=0x0, queued=1 failed in 2 of 2 runs. With it, the XAudio2 check passes in 2 of 2, and 48 of the title's checks pass. The test still fails on user32 … not cloaked (Wine) and files: delete hides the file, which also failed in runs without it.
  • hle::xaudio2 lib tests, each in its own process: 11 of 11 pass, get_state_names_the_oldest_buffer_of_a_voice_that_is_not_decoded and queued_contexts_follow_submits_and_flushes among them. The other 9 passed before it too.

Not tested: Windows, main, a title with audio.

AI use: Claude Code with Claude Opus 5.5 ran the tests and wrote this report.

**@⁠vakaobr** on GitHub · 2026-11-25 16:15 UTC · [original](https://github.com/xcl-dev/xcl/pull/1698#issuecomment-7167729035) Tested `e2ee5c0` on a Mac: the test title's Opus check passes with it. **Tested** (MacBook Pro M5 Pro, macOS 27.2.1, CrossOver 26.3.0, D3DMetal 3.0, no libopus, Rust 1.100.0 `x86_64-pc-windows-gnu`, debug). Cherry-picked onto the Mac branch from #258 (`vakaobr/xcl` `mac/integration`, which already has #890's commit through `mac7`, plus #750 so the title gets that far), not onto `main`. - `e2e::test_title_runs_and_game_folder_is_untouched`: without it, `XAudio2 … Opus GetState: ctx=0x0, queued=1` failed in 2 of 2 runs. With it, the XAudio2 check passes in 2 of 2, and 48 of the title's checks pass. The test still fails on `user32 … not cloaked` (Wine) and `files: delete hides the file`, which also failed in runs without it. - `hle::xaudio2` lib tests, each in its own process: 11 of 11 pass, `get_state_names_the_oldest_buffer_of_a_voice_that_is_not_decoded` and `queued_contexts_follow_submits_and_flushes` among them. The other 9 passed before it too. **Not tested:** Windows, `main`, a title with audio. AI use: Claude Code with Claude Opus 5.5 ran the tests and wrote this report.
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/1698/head:github-bot/gh-1698'
git switch 'github-bot/gh-1698'

Merge

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