XAudio2: an XMA voice keeps the decoder's channels beyond 8 #1277
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1287"
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 emirduran707 on 2026-11-24T14:20:42Z.
The XMA2 decoder accepts up to 16 channels (
xma2::MAX_CHANNELS), and a decoded XMA voice is created with the decoder's channel count. Butpcm16_for_rateclamped it to 8, so a voice with 9–16 channels got an 8-channel PCM voice. Each decoded frame still carried all its channels: with 10 channels, XAudio2 read every 10 samples as 1.25 frames of 8 channels, so the channels landed on the wrong speakers, drifted every frame, and the buffer played 1.25 times too long (2 times with 16 channels). XAudio2's limit isXAUDIO2_MAX_AUDIO_CHANNELS(64). On this machine, xaudio2_9 created plain PCM16 voices of 9, 10, 12, 16, 32 and 64 channels that played at the right length, and refused 65 (XAUDIO2_E_INVALID_CALL).pcm16_for_ratenow clamps to 1–64. The XMA voice's state takes the decoder's channel count too: the silence that stands in for an undecodable buffer is sized from it, and with 8 there Windows refused the submit of a 10-channel voice. Silent fallback voices and Opus voices still use 8, as before.What is in it
crates/xcl/src/hle/xaudio2.rs:pcm16_keeps_up_to_64_channels, which needs no device;xma_voice_keeps_the_decoders_ten_channels, which skips without an audio device. It uses anXMA2WAVEFORMATEXwith 10 channels in 5 streams: the voice reports 10 channels, and an undecodable buffer submits.Tested
cargo test --workspace -- --test-threads=4onfe5b1f3: 743 passed, 0 failed, 41 ignored; no SKIPPED GPU tests (the audio tests ran; an audio device is present)pcm16_keeps_up_to_64_channelsleft: (8, 16, 768000),right: (10, 20, 960000); with it both new tests passRegression run
main:
this PR:
Not tested
avg_bytesin the same function): the two merge cleanly, and its test's 8-channel case is unchanged by the 64 clamp; not run together.AI use
🤖 Generated with Claude Code
Imported from ivall/xcl. Originally posted by futurepro62 on 2026-11-24T14:34:39Z.
Full-suite run, since this PR has no test report yet. Tested exact head
fe5b1f3(on its base47efa2e).Tested
cargo build --workspace, thenXCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4: 743 passed, 0 failed, 41 ignored. SKIPPED (no wave64):gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware.pcm16_keeps_up_to_64_channels,xma_voice_keeps_the_decoders_ten_channels.Not tested
AI use
Imported from ivall/xcl. Originally posted by thehollowedone on 2026-11-24T14:35:10Z.
Independent native 16-channel XMA check on
fe5b1f3and its parent930e8b4. Windows 11 build 26300, system XAudio2 2.9, Rust 1.99.1 MSVC, debug.I submitted a synthetic XMA2 packet that produces no decoded samples to a muted voice. With the PR, the native voice reported 16 input channels and queued 15,360 zero PCM bytes for 480 frames. XAudio2 consumed exactly 480 source frames, drained the queue, and XCL freed the fallback buffer. The parent consumed 480 frames too, but its voice had eight channels and queued only 7,680 bytes. The stock 10-channel test also passed without a skip.
This checks native playback of synthetic fallback silence. Valid multichannel XMA decoding and retail audio were outside this run. AI-assisted. Codex (GPT-6, exact variant unavailable) wrote and ran the scratch fixture and drafted this report.
Imported from ivall/xcl. Originally posted by S1m0ne1997 on 2026-11-25T14:46:26Z.
Test report for
fe5b1f3b81b1ef64242c7ad1a8ef5f075b68d74a(this PR's head), for #1607.Tested
rustc 1.100.0 (0ef1bc386 2026-11-09)x86_64-pc-windows-msvc, debug.cargo build --workspace, thencargo test --workspace -- --test-threads=4at the head: 743 passed, 0 failed, 41 ignored.gpu_geometry_wave32_prefix_count_over_a_mask(no wave64),gpu_wave32_program_in_wave64_hardware(no wave64).Regression run (retail title,
scripts/smoke.ps1 -Seconds 60, release;mainbuilt from the commit in its block, this PR from its head with no changes tocrates/, both run with thescripts/smoke.ps1ofmain, which hashes the name of the game folder)main:
this PR:
Not tested
AI use: Claude Code with Claude Opus 5.5 ran the build, the suite and the regression run and wrote this report at my request.
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-26T01:17:35Z.
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, 26 ignored.Thanks!
— Devin
Imported from ivall/xcl. Originally posted by Decodere on 2026-11-27T13:08:36Z.
Independent desktop NVIDIA verification of PR #1287 at head
fe5b1f3b81b1ef64242c7ad1a8ef5f075b68d74a(1commit; exact parent & merge-base:47efa2ecea0a12934719ae69b81930cf02a4b1c3, pre-#2555ancestor ofmain).Environment
7956 MiBreported by D3D12, Wave32-only Ada), driver32.0.16.2114(NVIDIA621.14, WDDM 3.2)31.9 GiBusable), Windows 11 Home26200(Developer Mode off)rustc 1.100.0 (0ef1bc386 2026-11-09)MSVC, DXC1.9.2609.5,--releaseTargeted tests & build (
fe5b1f3b)cargo test --release -p xcl --lib -- --nocapture pcm16_keeps_up_to_64_channels xma_voice_keeps_the_decoders_ten_channels(3 consecutive runs)2 passed; 0 failed; 0 ignored; 719 filtered out× 3 (0.07s,0.05s,0.06s,0skipped; live Windows 11 system XAudio2 2.9 created 10-channel XMA2 voice and accepted undecodable silence buffer withS_OK)cargo test --release -p xcl --lib -- --nocapture hle::xaudio2::(3 consecutive runs)11 passed; 0 failed; 0 ignored; 710 filtered out× 3 (0.15s,0.15s,0.13s,0skipped; live Windows 11 system XAudio2 2.9 + Media FoundationMSOpusDecoder+hle::xma2)cargo build --release -p xcl1m 17s, exit0,0new warnings inxaudio2.rs)Paired quiet 60 s retail smoke (
title: 29640639)(Note:
scripts/smoke.ps1at47efa2ecpredates9683e7a6and printed the local folder basename ontitle:; replaced below with the standard9683e7a6title hash29640639, with all measured fields verbatim.)Exact parent & merge-base (
47efa2ecea0a12934719ae69b81930cf02a4b1c3, cached baseline on the same machine):PR #1287 (
fe5b1f3b81b1ef64242c7ad1a8ef5f075b68d74a):Limits of coverage
pcm16_keeps_up_to_64_channels,xma_voice_keeps_the_decoders_ten_channels, and the fullhle::xaudio2::suite (11/11,0skipped) passed3/3against the host's live Windows 11 system XAudio2 2.9 runtime, directly verifying 10-channel XMA2 voice creation (GetVoiceDetailsInputChannels == 10) and undecodable-buffer silence framing (S_OK) without hitting the no-audio-device skip path.0device removals,0crashes, steady 60 Hz) without confirming whether this title instantiates >8-channel XMA2 voices; single-run frame/commit delta vs. the cached parent reflects normal startup variance.AI disclosure: test execution and report drafting assisted by Google Antigravity (Gemini 4 Neon).
Imported from ivall/xcl. Originally posted by throny on 2026-11-28T13:55:36Z.
merge-check claim
head:
fe5b1f3b81Imported from ivall/xcl. Originally posted by throny on 2026-11-28T14:12:27Z.
merge-check
base:
e13d6250head:
fe5b1f3b81merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2132 passed, 10 failed, 48 ignored (26 SKIPPED lines). The 10 failures are the ones main itself has at
e13d6250on this GPU (#3093: the nine since #2959 and, since today, gpu::dxil::msaa_tests::direct_msaa_loads_precede_get_dimensions), the same set with and without this PR; base alone: 2130 passed, 10 failed, 48 ignored.review: the bounds hold: the decoder's channel count is limited to 16 by its stream configuration, the PCM conversion clamps the channel count, the Opus path refuses more than 8, the silence fallback is clamped to the buffer limits, and the 8-channel clamp of the info block is overridden only in the decoded path. Minor: the new test asserts only success for the undecodable buffer, not the byte count of ten channels, and it returns without a SKIPPED line when there is no audio device.
performance: only voices with more than 8 channels, which now get 10 to 16 channels of PCM; negligible.
verdict: safe to merge
hardware / tool and model: RTX 4080 16 GB (621.40), i9-12900K, Windows 11 26300, Rust 1.100.0, debug. Claude Code; merge, build and suite run by Claude Fable 5.2, diff review by Claude Opus 5.5 (every hunk read; nothing run on the GPU beyond the suite).
Imported from ivall/xcl. Originally posted by jsalzy on 2026-11-30T01:40:38Z.
merge-check claim
head:
fe5b1f3b81Imported from ivall/xcl. Originally posted by relativespace2K on 2026-11-30T01:45:11Z.
Test report only. I withdraw my merge-check claim: this head already has a merge check and another claim, and the two slots are theirs.
head:
fe5b1f3b81b1ef64242c7ad1a8ef5f075b68d74a, test-merged ontomain53e85fb1, merge clean (one file,crates/xcl/src/hle/xaudio2.rs).Tested
cargo build --workspace-> ok, thencargo test --workspace --no-fail-fast -- --test-threads=4-> 2790 passed, 6 failed, 49 ignored.53e85fb1alone (2788 passed, 6 failed, 49 ignored there):gpu::dxil::compact_tests::gpu_compact_form_with_micro_blocks_and_literal_table_runs_as_the_plain_form,gpu::recomp::pso::shader_cache_tests::console_mesh_caches_hlsl_compute_pass_in_memory_and_on_disk,hle::d3d12x::standin::tests::concurrent_shell_miss_reuses_winner_and_releases_loser_pipeline,ram_budget::tests::windows_takes_a_working_set_maximum_and_lifts_it,two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs(in--test gpu_two_pass_cache_e2e, so five tests give six failures).pcm16_keeps_up_to_64_channelsand, on this machine,xma_voice_keeps_the_decoders_ten_channels; run alone with--nocaptureit prints no "skipping: no audio device", so the mastering voice and the 10-channel source voice were really created rather than silently skipped.Not tested: a release build, a game run.
AI use: DeepSeek Harness coding agent, model DeepSeek V4.1 Flash (test merge, build, suite, log reading).
Imported from ivall/xcl. Originally posted by jsalzy on 2026-11-30T01:45:27Z.
yo im already checking this
Imported from ivall/xcl. Originally posted by jsalzy on 2026-11-30T01:53:41Z.
merge-check
base:
9335bc0d86head:
fe5b1f3b81merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2803 passed, 1 failed, 50 ignored; SKIPPED: 28 (22 no wave64 on this GPU; 3 per-lane form refused (#1426 semantics); 2 no heap windows (opt-in XCL_HEAP_WINDOWS=1); 1 driver cache cannot be disabled without Windows Developer Mode); failing: hle::d3d12x::standin::tests::concurrent_shell_miss_reuses_winner_and_releases_loser_pipeline (standin.rs:459, left (0, 1, 1), right (0, 0, 1)), fails on base too. Main alone at
9335bc0: 2800 passed, 2 failed, 50 ignored: the same standin test, and two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs (gpu_two_pass_cache_e2e.rs:472, in its warm child run), which passed on the merge result and does not involve audio. The PR's two new tests (pcm16_keeps_up_to_64_channels, xma_voice_keeps_the_decoders_ten_channels) pass; the voice test returns early without an audio device and its output is captured, so this run does not show whether it reached CreateSourceVoice.review: no blocking finding; whole diff read (one file). pcm16_for_rate now clamps to 1..64 instead of 1..8. The only caller that can pass more than 8 is the XMA decoder path (create_decoded_voice with dec.channels(), up to 16 from the stream configuration); xma_info and opus_format still clamp to 8 and the Opus decoder refuses more than 8, so the PCM fallback and Opus voices are unchanged. The XmaInfo handed to the decoder takes the decoder's channel count, so silence for an undecodable buffer is sized in the voice's own frames. Minor: the voice test asserts only S_OK for the undecodable buffer, not the silence's length, and it skips with eprintln instead of a SKIPPED line. Overlap to settle: #1437 (open) routes pcm16_for_rate through a 1..8 channel clamp; the two disagree on the limit, so whichever merges second has to pick one. Not a duplicate.
performance: none for voices of up to 8 channels; voices of 9 to 16 channels now carry all their channels (up to 2x the PCM of the old 8-channel clamp).
verdict: safe to merge
hardware / tool and model: RTX 4070 SUPER 12 GB (621.24 / 32.0.16.2124), Ryzen 7 7800X3D, 32 GB, Windows 11 Pro 25H2 26200.9974, Rust 1.100.0, debug / Claude app (Claude Opus 5.5): merge, build and suite run on this PC with git and cargo only; diff review by Claude Opus 5.5.