Repository navigation
XAudio2: pure-Rust XMA1/XMA2 audio decoder - #20
Merged
Merged
Conversation
This was referenced Nov 21, 2026
Collaborator
|
Reviewed and merged, thanks. FFmpeg LGPL-2.1+ provenance is in the file header and THIRD_PARTY.md (compatible with GPL-2.0-only); the decoder is safe Rust, the unwraps are test-only and the bit reader reads zeros past the end, so corrupt input cannot panic the audio path. Clippy nits for later: a 14-argument function, two manual |
This was referenced Nov 21, 2026
rootw0rm
pushed a commit
to rootw0rm/xcl
that referenced
this pull request
Nov 27, 2026
…wports/scissors/topo) into ListDrawRecord List slots xcl-dev#34 (SetGraphicsRootSignature), xcl-dev#50 (OMSetRenderTargets), xcl-dev#47 (IASetIndexBuffer), plus PC-side xcl-dev#20/xcl-dev#21/xcl-dev#22 (topology, viewports, scissors) store into ListDrawRecord. SetPipelineState (xcl-dev#25) now merges instead of overwriting so PSO-first or state-first order both keep the full record. Store-only: no draw, no validation, no execute; triangle/ bias FAILs stay failing. Evidence: new draw_s2_list_state_recorded_pre_draw fails pre-change (S2 symbols absent at HEAD: grep count 0) and passes post; full lib 806 passed, 0 failed, 1 ignored; both cargo checks clean; title null 4 FAILs identical to HEAD-baseline worktree run (triangle, present, bias-xcl-dev#94, all D3D12.X GPU-only, + pre-existing files:delete also on HEAD), delta 0; Vulkan 3 (triangle, bias-xcl-dev#94 + same files:delete); retail HOLDS (exit 139 @ exe+0x2237320, SIGSEGV fault 0, 20 stubs, xgr XAsync/XNetworking/XUser, 0 d3d12).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements real XMA1 (
0x0165) and XMA2 (0x0166) audio decoding for XAudio2 on top of currentmainin pure safe Rust — closing out the remaining audio gap listed inREADME.mdandcrates/xcl/src/hle/xaudio2.rswith zero external runtime DLLs and zero new Cargo dependencies.The decoder and static Huffman/DSP tables are cleanly ported from FFmpeg's LGPL-2.1+
wmaprodec.c/wmaprodata.h/wma.c/sinewin_tablegen.h/float_dsp.c/tx_template.c(GPL-2.0-only compatible under LGPL-2.1 §3, with GPL-2.0 §2a provenance headers in the files andTHIRD_PARTY.md).Summary of changes
crates/xcl/src/hle/xma2/(mod.rs,tables.rs)StreamConfig): supportsXMA2WAVEFORMATEX(cbSize == 34), legacyXMA2WAVEFORMAT(rev 3/4), andXMAWAVEFORMAT(0x0165), up to 8 interleaved 1–2 ch streams (16 channels total).Decoder): decodes fixed 2048-byte XMA1/XMA2 packets with cross-packet bit-reservoir frame assembly (num_bits_prev_frame), multi-streamskip_packetsrouting,0xFFFFFFFFpadding-packet skipping, 64-sample initial encoder-delay skip,trim_start/trim_endtrimming, and overlap-add EOF flushing.imdct_half, and sine window overlap-add.xma2/xma1decoders: all 7 synthetic test vectors (mono 48 kHz tone, stereo M/S transform, non-uniform 256/128 subframes + RL scale factors, all vector/RLE/quant-escape paths at 32 kHz, cross-packet frames +trim_start/trim_end, 5.1 6-channel 3-stream interleaving, and XMA1 24 kHz stereo) match FFmpeg's output to< 1.5e-7float32 (0–1 LSB PCM16).crates/xcl/src/hle/xaudio2.rsDecodedVoiceState/DecodedCallback) to back both Opus (hle::opus) and XMA1/XMA2 (hle::xma2) voices without code duplication.WAVE_FORMAT_XMA(0x0165) andWAVE_FORMAT_XMA2(0x0166) inCreateSourceVoice, decoding submitted buffers to PCM16, clamping play/loop regions, managing decoded PCM buffer lifetimes untilOnBufferEnd/DestroyVoice, mapping contexts back inGetState, and flushing decoder state onFlushSourceBuffers/XAUDIO2_END_OF_STREAM.xma_buffers_decodedandxma_decode_errorsinAudioStats(report.json -> audio).hle::xma2covering fast IMDCT vs naive reference, all 7 Huffman tables round-tripping every symbol, XMA1/XMA2 config parsing, all 7 FFmpeg-verified bitstreams, streaming chunk-by-chunk parity with single-shot decode, 5.1 channel isolation,0xFFFFFFFFpadding packets, and corrupt/empty input safety.hle::xaudio2(xma2_source_voice_decodes_and_manages_lifetime) covering valid XMA2 playback, corrupt-buffer silence fallback,GetStatecontext mapping,FlushSourceBuffers, callback forwarding, and zero decoded-buffer leaks.tests/testtitle/src/audio.rs,tests/testtitle/src/main.rs, andcrates/xcl/tests/e2e.rsto submit a real 48 kHz mono XMA2 packet and assertxma_voices == 1,xma_buffers_decoded == 1,xma_decode_errors == 0,silent_voices == 0, andbuffers_silenced == 0.README.mdandTHIRD_PARTY.md.Testing
cargo build --workspace && cargo test --workspace -- --test-threads=4:e2e– XMA2 and Opus 0.1 s voices both decode and finish in ~96 ms)console_dlls_e2e), 1 passed (console_shaders), 6 passed (gpu_pso_e2e), 3 passed (xg_oracle)