XAudio2: validate and clamp voice sample rates and channel counts #1437
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!1437
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1437"
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?
@slopgobblercobbler on GitHub · 2026-11-24 15:57 UTC · original
slopgobblercobbler:fix/xaudio2-sample-rate-channel-bounds→main· +310 −8 · 1 files · 1 commits · openSummary
Audits and bounds XAudio2 voice sample rates and channel counts in
crates/xcl/src/hle/xaudio2.rs:XAUDIO2_MIN_SAMPLE_RATE(11,025 Hz),XAUDIO2_MAX_SAMPLE_RATE(192,000 Hz),XAUDIO2_MIN_CHANNELS(1),XAUDIO2_MAX_CHANNELS(8), andXAUDIO2_E_INVALID_CALL(0x88960001).is_valid_sample_rate,is_valid_channel_count,clamp_sample_rate(defaults 0 to 48 kHz, clamps to [11025, 192000]), andclamp_channel_count(clamps to [1, 8]).pcm16_for_rate,opus_format, andxma_info: clamp channel counts to 1..=8 and sample rates to 11025..=192000 Hz to prevent invalid parameter rejection by host XAudio2.create_source_voice: added fallback clamping for plain PCM formats rejected by host XAudio2 due to out-of-bounds rates/channels, retrying with clamped PCM16 so titles with unusual audio specs continue playing via silent voice rather than failing creation.create_mastering_voice: sanitized out-of-bounds channels (> 8) or invalid sample rates to default native endpoint format.sample_rate_and_channel_bounds_validation_and_clampingandclamped_voices_accepted_by_windows_xaudio2.Changes
crates/xcl/src/hle/xaudio2.rs:Tested
cargo test -p xcl -- xaudio2: 11 passed, 0 failed (100% pass rate).Not Tested
AI Use
Co-Authored-By: Claude Code (Claude Opus 5.5) / Gemini Antigravity
@Anon64 on GitHub · 2026-11-24 16:24 UTC · original
Regression run for this PR: head
ac222f7, based onmaincbea872. RTX 3060 12 GB (581.80, wave32), Windows 11 26200, release,XCL_NETWORK=0, A pressed every 4 s from 20 s,scripts/smoke.ps1on a retail title for 60 s.main
cbea872:this PR:
No device removals or crashes; 113 % of main's frames, 118 % of its peak commit.
Peak commit in both runs is mostly the pipeline preload's DXC compiles on this machine (#1035; 23 GB on
mainwithXCL_PSO_PRELOAD=0), so it varies run to run.Not tested: the whole suite; whether the title reaches the changed code in these 60 s.
Written with Claude Code (Claude Opus 5.5) from runs on this machine.
@futurepro62 on GitHub · 2026-11-24 16:53 UTC · original · edited 2026-11-24 17:10 UTC
Full-suite run, since this PR has no test report yet. Tested exact head
ac222f7(on its basecbea872).Tested
cargo build --workspace, thenXCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4: 758 passed, 0 failed, 41 ignored. SKIPPED (no wave64):gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware.sample_rate_and_channel_bounds_validation_and_clamping,clamped_voices_accepted_by_windows_xaudio2.XCL_ADAPTER=radeon),cargo test --workspace -- --test-threads=4: 758 passed, 0 failed, 41 ignored, no skips.Not tested
AI use
@DavidM1911 on GitHub · 2026-11-24 18:52 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~21 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodifiedmain.)Thanks!
@Toons29 on GitHub · 2026-11-25 03:31 UTC · original
Regression run of
e49f75d1on the retail title, for this PR's Regression run section. Both blocks are fromscripts/smoke.ps1as printed, not edited:mainon4178e888, this PR on its head commit with no uncommitted changes, same title and time.Against the limits in CONTRIBUTING.md: 101 % of
main's frames, 100 % of its peak commit, no crash, no device removal.AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0,
cargo build --release -p xcl, 60 s,XCL_NETWORK=0. This is a regression check only: it does not show whether the run reaches the code this PR changes.AI use: Claude Code (Claude Opus 5.5) built both trees and ran
scripts/smoke.ps1; I checked the blocks before posting.@gut0to on GitHub · 2026-11-24 17:05 UTC · original
On
crates/xcl/src/hle/xaudio2.rsline 1032 (outdated):CreateMasteringVoice also requires a nonzero
InputSampleRateto be a multiple ofXAUDIO2_QUANTUM_DENOMINATOR(100). This check treats 11,025 Hz as valid and passes it toorig, but XAudio2 rejects that rate for a mastering voice, so this fallback can still fail. Please default rates that violate the quantum requirement and add a test for 11,025 Hz. AI-assisted review; I checked the CreateMasteringVoice contract and the XAudio2 header.@slopgobblercobbler on GitHub · 2026-11-24 18:25 UTC · original
On
crates/xcl/src/hle/xaudio2.rsline 1032 (outdated):Addressed in commit
e49f75d: updated CreateMasteringVoice to checkate % XAUDIO2_QUANTUM_DENOMINATOR == 0 for non-zero InputSampleRate, defaulting non-conforming rates (such as 11,025 Hz) to 0 (endpoint native rate). Also added mastering_voice_quantum_sample_rate_defaults_to_native verifying 11,025 Hz defaults to native format and passes voice creation against Windows XAudio2.
@DavidM1911 on GitHub · 2026-11-26 05:13 UTC · original
Re-verification on RTX 3060 Ti (Windows 11), new head merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved.Thanks!
— Devin
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.