Skip to content

[upstream #890] XAudio2: GetState names the oldest queued buffer when the host gives none - #188

Closed
ufoptg wants to merge 1 commit into
mainfrom
upstream-pr/890
Closed

ufoptg wants to merge 1 commit into
mainfrom
upstream-pr/890

Conversation

@ufoptg

@ufoptg ufoptg commented Nov 24, 2026

Copy link
Copy Markdown
Owner

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 xcl-dev#258 (comment).

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 [upstream #1898] Direct DXIL: truncate s instead of returning native on special values in round_exact #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

  • Not run yet. I will add an xcl-smoke pair (main and this head) from the Mac before taking this out of draft.

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.

Mirror of xcl-dev#890 (auto-synced, do not edit).

…none

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 <noreply@anthropic.com>
@ufoptg

ufoptg commented Nov 25, 2026

Copy link
Copy Markdown
Owner Author

Upstream PR xcl-dev#890 was closed or merged.

@ufoptg ufoptg closed this Nov 25, 2026
@ufoptg
ufoptg deleted the upstream-pr/890 branch November 25, 2026 00:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants