XAudio2: compute mixed stereo and mono XMA2WAVEFORMATEX stream layouts #2022
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2032"
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 Decodere on 2026-11-25T01:20:25Z.
Fixes
StreamConfig::from_xma2_wfxincrates/xcl/src/hle/xma2/mod.rsso standardXMA2WAVEFORMATEXheaders (cbSize == 34) accept valid mixed stereo + mono multi-stream layouts whereceil(channels / 2) < num_streams < channels(such as 5.1 4-stream[2, 2, 1, 1], 4.0 3-stream[2, 1, 1], 5.0 4-stream[2, 1, 1, 1], and 7.1 5/6-stream). Part of #1488 (XCL-BT-015).Previously, whenever
num_streams != channels,from_xma2_wfxassigned 2 channels to every streamiwith(i + 1) * 2 <= channelsand 1 otherwise. For valid mixed stereo/mono layouts like(channels = 6, num_streams = 4), that assigned[2, 2, 2, 1](sum 7 != 6) and rejected the header withXMA2 stream count 4 does not match 6 channels. Because each XMA2 stream holds 1 or 2 channels, any feasible(channels, num_streams)pair withnum_streams <= channels <= num_streams * MAX_CHANNELS_PER_STREAMuniquely hasstereo = channels - num_streams2-channel streams andnum_streams - stereo1-channel streams.What is in it
crates/xcl/src/hle/xma2/mod.rs:StreamConfig::from_xma2_wfx(extradata.len() == 34), validatech < num_streams || ch > num_streams * MAX_CHANNELS_PER_STREAMand assignstereo = ch - num_streams2-channel streams followed by 1-channel streams (subsuming thenum_streams == channelsspecial case while preserving packed,NumStreams == 0default, and invalid stream-count behavior).stream_config_xma2_wfx_assigns_mixed_stereo_and_mono_streamscovering valid mixed stereo/mono layouts,Decoder::newconstruction, invalid stream counts, and an end-to-end 4-stream 5.1 ([2, 2, 1, 1]) interleaved decode verified against standalone stereo and mono reference decodes.Tested
0ef1bc386), DXC 1.9.2609.5 (01b62ad4), release build.hle::xma2::tests::stream_config_xma2_wfx_assigns_mixed_stereo_and_mono_streamsfails without the fix (channels=4 streams=3: XMA2 stream count 3 does not match 4 channels).cargo test --release -p xcl --lib hle::xma2::tests -- --nocapture: 8 passed, 0 failed, 0 ignored.cargo test --release -p xcl --lib hle::xaudio2 -- --nocapture: 9 passed, 0 failed, 0 ignored.cargo build --release --workspace+cargo test --release --workspace -- --test-threads=4: 1063 passed, 0 failed, 45 ignored across 20 test binaries.SKIPPEDGPU/runtime tests on this adapter (24 lines):no wave64subcases acrossgpu::recomp::lower::tests(4),gpu::recomp::lower_dxil::tests(13), andgpu::recomp::tests(2)#1426refusals (V_MUL_F16,V_PK_MUL_F16,V_CVT_F16_F32) ingpu::recomp::lower_dxil::testsshaders::tests::pso_measurement_compiles_an_exact_synthetic_record: cannot disable the driver cache (Windows Developer Mode is required)heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windowsRegression run
scripts/smoke.ps1onmain(656c0e8ca070bdc9d7cb197d264792ef49304865) and on this PR's head commit (b32eadfea2c6897bc41b2e4a90ae58c30e25ba56):Not tested
XMA2WAVEFORMATEXheaders beyond the synthetic 4-stream 5.1 bitstream decode test.XMA2WAVEFORMATEXcannot encode because it carries onlyNumStreamsand no per-streamXMA2STREAMFORMATtable.--release).AI use
StreamConfig::from_xma2_wfx, implemented the layout calculation fix, unit and 4-stream 5.1 decode regression tests, and PR description; all tests and paired 60s smoke runs were executed and verified locally on RTX 4060 hardware.Imported from ivall/xcl. Originally posted by raylitebull on 2026-11-25T01:25:42Z.
Code review on
b32eadf:StreamConfig::from_xma2_wfxincrates/xcl/src/hle/xma2/mod.rscleanly validatesch < num_streams || ch > num_streams * MAX_CHANNELS_PER_STREAMand partitionsstereo = ch - num_streams(2 channels) followed by mono streams (1 channel), supporting mixed stereo + monoXMA2WAVEFORMATEXlayouts (cbSize == 34) such as[2, 2, 1, 1].stream_config_xma2_wfx_assigns_mixed_stereo_and_mono_streamsthoroughly covers valid packed, mixed, all-mono, and invalid channel/stream combinations plus an end-to-end 5.1 4-stream decode against stereo/mono reference packets.PR descriptionis green andBuild and test (Windows, no GPU)is currently running.Remaining before merge:
Build and testfinishing green plus dual-vendor (AMD + NVIDIA) / independent test verification onb32eadf.Imported from ivall/xcl. Originally posted by JJAutoCompare on 2026-11-25T02:25:58Z.
PR #2032 verification on STOR-WINLAB
Verified the live PR head
b32eadfea2from refs/pull/2032/head, with a clean worktree. Fetched main wascbc296ab65. git merge-tree --write-tree origin/main HEAD exited 0 and produced tree 24580937c02cc9b28262b7f89fcada21c50ccbab.What is in it
Tested
Not tested
AI use
Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified the counts against
pr2032-suite.logand published this report.Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T04:28:34Z.
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!
Imported from ivall/xcl. Originally posted by upipibi on 2026-11-26T21:29:17Z.
Tested head
b32eadfea2c6897bc41b2e4a90ae58c30e25ba56(merge-base with main656c0e8) on Windows 11 Pro 26100, rustc 1.100.0 MSVC, debug, CPU only (no GPU opened).cargo test -p xcl --lib hle::xma2 -- --test-threads=1: head 8 passed, 0 failed, 0 ignored; merge-base 7 passed, 0 failed. New on head:stream_config_xma2_wfx_assigns_mixed_stereo_and_mono_streams. Applied to the merge-base656c0e8ca070bdc9d7cb197d264792ef49304865code (test hunk only, no fix),hle::xma2::tests::stream_config_xma2_wfx_assigns_mixed_stereo_and_mono_streamsfails:channels=4 streams=3: XMA2 stream count 3 does not match 4 channels, 0 passed, 1 failed.Not tested: full suite, GPU, retail title. AI-assisted (Claude Code, Claude Sonnet 5.5 ran the tests; Claude Opus 5.5 checked and posted).
Imported from ivall/xcl. Originally posted by throny on 2026-11-29T00:12:15Z.
merge-check claim
head:
b32eadfea2Imported from ivall/xcl. Originally posted by throny on 2026-11-29T00:29:49Z.
merge-check
base:
b10cc4c6head:
b32eadfea2merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2608 passed, 0 failed, 49 ignored on the merge result with main
b10cc4c6(27 SKIPPED lines).review: the arithmetic is safe (channel and stream counts are already bounded, the subtraction runs after the range check) and every header main accepts today gives the same layout as before. The change is that headers main refuses, with more streams than a fully packed layout needs, are now accepted with a guessed order: stereo streams first, then mono ones. The header format does not say which streams are stereo, and nothing in the PR or the thread cites a real stream or an encoder's rule for it. If the guess is wrong, the result is scrambled audio where today the header is refused. main's newer audio work did not touch this file.
performance: none.
verdict: not yet: evidence for the stereo-first order (a real stream that decodes right, or a documented encoder rule).
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-30T02:49:54Z.
merge-check claim
head:
b32eadfea2Imported from ivall/xcl. Originally posted by jsalzy on 2026-11-30T03:01:59Z.
merge-check
base:
2bfb6d1a58head:
b32eadfea2merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2813 passed, 2 failed, 51 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: (1) 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; (2) two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs (gpu_two_pass_cache_e2e.rs:472, in a child run; its child's own result line is printed inside the failure, so cargo's total reads 3), passes on base this time, but it is a D3D12 driver-cache test with no audio in it and it is unstable here: it failed in 3 of 10 suite runs on this machine tonight, twice on main alone (
9335bc0). Main alone at2bfb6d1: 2813 passed, 1 failed (the standin test), 51 ignored. The PR's new test stream_config_xma2_wfx_assigns_mixed_stereo_and_mono_streams passes.review: the arithmetic is safe (the count check runs before ch - num_streams), and every header main accepts today gives the same stream layout as before (fully packed 2+2+...+1, all mono, NumStreams 0). What changes is that headers with ceil(ch/2) < NumStreams < ch, which main refuses, are now accepted with stereo streams first and mono streams last. XMA2WAVEFORMATEX does not say which streams are stereo, and the new end-to-end test builds its 5.1 / 4-stream input in that same order, so it shows the decoder follows the assumed layout, not that encoders write it. The first check's point is still open: if real streams order them differently, the result is scrambled channels where today the header is refused. Related but different: #1446 and #1886 (open) reject 0- or >2-channel streams in Decoder::new; #1287 changes the PCM channel clamp. Not duplicates.
performance: none (format parsing at voice creation).
verdict: not yet: evidence for the stereo-first order (a real title's stream that decodes right with it, or a documented encoder rule); with that, the code itself has no finding.
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.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T07:13:31Z.
Triage (#1607) – head
b32eadfNo open or merged PR changes the
XMA2WAVEFORMATEXstream layout inStreamConfig::from_xma2_wfx.No problems found in the diff: for every layout main accepted (all mono, or
ceil(ch/2)streams) the newch - num_streamsstereo-first rule gives the same layout, and it adds the mixed counts main refused (e.g. 6 channels in 4 streams -> 2,2,1,1), with a decode test.Recommendation: keep open.
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
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.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.