Repository navigation
XAudio2: real Opus decoder via Windows MSOpusDecoder MFT - #3
Merged
Merged
Conversation
- Add hle::opus: RFC 6716 TOC/packet parser (exact Table 2 frame durations for all 32 configs, codes 0-3, 120 ms limit), RFC 7845 OpusHead parser/builder, framing extractor (Ogg Opus, [u16 LE len][pkt] blocks with zero padding, raw packets), and stateful Decoder backed by dynamically loaded mfplat.dll + MSOpusDecoder.dll (1-2 ch single-stream and 3-8 ch multistream via RFC 6716 Appendix B self-delimited splitting). - Wire Opus voices (WAVE_FORMAT_OPUS 0x704F and WAVE_FORMAT_EXTENSIBLE with MFAudioFormat_Opus) in hle::xaudio2 to decode to PCM16, wrap IXAudio2VoiceCallback to manage decoded buffer lifetimes and forward the title's original pBufferContext, flush decoder state on FlushSourceBuffers, and map tokens back in GetState. - Add AudioStats counters (opus_voices, opus_buffers_decoded, opus_decode_errors), unit tests covering SILK/Hybrid/CELT/5.1/framing/lifetime, and an Opus voice check in tests/testtitle + e2e.
raylitebull
force-pushed
the
opus-decoder
branch
from
November 21, 2026 16:32
c3b10f1 to
2bd8fcc
Compare
ivall
added a commit
that referenced
this pull request
Nov 21, 2026
# Conflicts: # crates/xcl/Cargo.toml
ivall
added a commit
that referenced
this pull request
Nov 21, 2026
…io2 part, superseded by PR #3) # Conflicts: # crates/xcl/src/hle/xaudio2.rs
This was referenced Nov 24, 2026
rootw0rm
pushed a commit
to rootw0rm/xcl
that referenced
this pull request
Nov 27, 2026
The null device's plain lists ran the console memory slots (xcl-dev#60/xcl-dev#61/ xcl-dev#69-xcl-dev#72/xcl-dev#89/xcl-dev#93) as logging stubs, so the title's console_list_methods check read back 0x0 on the null backend while the identical immediate host writes already passed on Vulkan lists. The vtable now wires the same VulList_* functions into Kind::CommandList; GetDevice (xcl-dev#7), the UAV barrier (xcl-dev#146) and AllocateUploadMemory (xcl-dev#148) stay Vulkan-only with their slices (barrier/upload ride with raytracing, which still fails on null at the OPTIONS5 tail-zero assert). Failing-first: the new null_list_shares_the_console_memory_methods test fails pre-route (slot 69 stub writes nothing) and passes now (write32/fill/copy/timestamp land, pre-satisfied wait returns, kickoff is a silent no-op), mirroring the title's asserts. Gates: check -p xcl --tests EXIT 0; check --workspace EXIT 0; lib 797 passed/0 failed/1 ignored (--test-threads=4). Title e2e, fresh roots: null 12->11 FAILs (Write32 fixed, byte-identical remainder), Vulkan 9 unchanged with the real present (640x360 token 0x1 on Intel Arc). Retail HOLDS (SIGSEGV exe+0x2237320, exit 139, called_stubs 20, 0 d3d12).
rootw0rm
pushed a commit
to rootw0rm/xcl
that referenced
this pull request
Nov 27, 2026
…ev#148 (XS) The null device left slot xcl-dev#18 a logging stub, so the title's raytracing_surface leg 2 read heap zeros ([0 x4]) instead of the RDNA2 BVH words; legs 3 (xcl-dev#148 upload, xcl-dev#146 barrier) were Vulkan-list-only, so the default title list had stubs there too. All three are pure host-memory operations (descriptor-word write, aligned zeroed alloc, a coherent single-queue no-op barrier), so the null objects share the Vulkan implementations with no GPU needed — same precedent as the xcl-dev#3 Execute leg sharing the console memory methods. Failing-first: new null_device_serves_the_raytracing_surface test fails pre-fix ([0 x4] vs the BVH words) and passes now; other view dimensions and nulls still pass through untouched (existing Vulkan helper test). Gates: check -p xcl --tests EXIT 0; check --workspace EXIT 0; lib 799 passed/0 failed/1 ignored (--test-threads=4). Title e2e, fresh roots: null 12->11 FAILs (raytracing_surface now PASSES; every other FAIL byte-identical, 0 new non-GPU), Vulkan 10 total incl. files (9 D3D12.X, raytracing absent — paths untouched). Retail HOLDS (SIGSEGV exe+0x2237320, exit 139, called_stubs 20, 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 Opus audio decoding for XAudio2 on top of current
mainusing Windows' built-inMSOpusDecoder.dllMedia Foundation transform (as noted inHANDOFF.md), with no additional third-party crates.Summary of changes
crates/xcl/src/hle/opus.rsOpusHeadbuilder & parser: supports 1–8 channels (mapping family 0 for mono/stereo, Vorbis mapping family 1 for 3–8 ch),pre_skip, andoutput_gain.OggS), single- and multi-block[u16 LE len][packet]...with optional trailing zero padding (matching the 2048 B AWC blocks), and raw RFC 6716 packets.Decoder: dynamically loadsmfplat.dllandMSOpusDecoder.dllviaDllGetClassObject(no static Media Foundation dependency; GPL-2.0 system-library compatible). Decodes 1–2 ch single-stream directly and 3–8 ch multistream (5.1/7.1) by splitting RFC 6716 Appendix B self-delimited sub-packets acrossstream_countMFT instances and interleaving via the channel map.crates/xcl/src/hle/xaudio2.rsWAVE_FORMAT_OPUS(0x704F) andWAVE_FORMAT_EXTENSIBLEwithMFAudioFormat_Opus, creating a PCM16 source voice backed byopus::Decoder(with RFC 6716-sized silence fallback ifMSOpusDecoder.dllis unavailable).IXAudio2VoiceCallbackto keep decoded PCM16 buffers alive at stable heap addresses untilOnBufferEnd(orDestroyVoice) while forwarding the title's originalpBufferContext.FlushSourceBuffers(HLE: implement mfplat.dll!MFResetDXGIDeviceManagerX with system fallback #22) to flush decoder state andGetState(test: accept all valid Windows MMDevice endpoint ID formats in audio test #25) to map internal buffer tokens back to the title'spCurrentBufferContext.opus_voices,opus_buffers_decoded, andopus_decode_errorstoAudioStats(report.json -> audio).hle::opuscovering all 32 RFC 6716 configs, codes 0–3, framing detection, real libopus packets across SILK/Hybrid/CELT/2.5–60 ms, 440/880 Hz tone verification, 5.1 surround channel isolation,pre_skip, 24 kHz output, andflush.hle::xaudio2covering format detection, region clamping, live Opus voice playback,GetStatecontext mapping, callback forwarding, and zero decoded-buffer leaks.0x704Fvoice (2048 B AWC-framed block) totests/testtitle/src/audio.rsand checked itsreport.jsonstats incrates/xcl/tests/e2e.rs.README.mdandTHIRD_PARTY.md.Testing
cargo build --workspace && cargo test --workspace -- --test-threads=4:e2e– XMA2 and Opus 0.1 s voices both finish in ~96 ms)console_dlls_e2e), 6 passed (gpu_pso_e2e)