[PR #2044] [MERGED] xapu: decode Opus packets through a Rust sidecar (RT-XAPU-OPUS-DECODE) #2050

Closed
opened 2026-11-26 21:19:51 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/2044
Author: @BubsMcgee
Created: 11/25/2026
Status: ✅ Merged
Merged: 11/26/2026
Merged by: @aslan2142

Base: main ← Head: rt-xapu-opus


📝 Commits (6)

📊 Changes

14 files changed (+1340 additions, -172 deletions)

View changed files

📝 docs/audio_hal_exe_calls.md (+20 -0)
📝 docs/runtime_imports.md (+14 -12)
📝 runtime/CMakeLists.txt (+72 -1)
➕ runtime/cmake/opus_decoder.cmake (+23 -0)
➕ runtime/opus_decoder/Cargo.lock (+16 -0)
➕ runtime/opus_decoder/Cargo.toml (+16 -0)
➕ runtime/opus_decoder/README.md (+33 -0)
➕ runtime/opus_decoder/leonida_opus_decoder.h (+44 -0)
➕ runtime/opus_decoder/src/lib.rs (+244 -0)
📝 runtime/shims/xapu_chad.cpp (+5 -118)
➕ runtime/shims/xapu_queue.cpp (+438 -0)
📝 runtime/test/xapu_chad_test.cpp (+221 -40)
➕ runtime/test/xapu_opus_test.cpp (+193 -0)
📝 scripts/build_runtime.ps1 (+1 -1)

📄 Description

Claimed as RT-XAPU-OPUS-DECODE (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7170709281).

Depends on: #1144 (RT-XAPU-CONNECT-LAYOUTS). The branch is stacked on #1144 and also merges main (b9320a118): the #1144 head predates a slot-133 kernel_writes fix and crashed early in a retail boot without it. When #1144 lands, this reduces to the decoder alone.

What and why

#1144 keeps the xapu command queue and layouts and leaves fill_silence() for a decoder; this wires one in:

  • runtime/opus_decoder: a Rust C-ABI crate over BSD-3-Clause opus-pure, built by cargo like runtime/xma_decoder (-DLEONIDA_REQUIRE_OPUS_DECODER=ON requires it; -DLEONIDA_OPUS_DECODER_LIB=<path> links a prebuilt one).
  • xapu_queue.cpp::fill() decodes each process packet into f32 PCM, honouring first_frame, frame_count, output_bytes and the deinterleaved option; without cargo it keeps the table-of-contents frame count and silence.
  • A decoder is created on activate and destroyed on deactivate/disconnect.

The layouts stay #1144's (credited to Marvisak/VIctory apu.rs, GPL-3.0-or-later); no VIctory source is copied, and the new files use leonida names.

Tested

  • xapu_opus (new): 29/29. A generated 440 Hz stereo packet decodes to 960 frames / 0x1E00 bytes with energy; first_frame / frame_count / output_bytes clipping; empty, null and stray-stream errors; deactivate and reactivate.
  • xapu_chad (#1144's): passes unchanged (layouts + silent path).
  • acphal, acphal_noncached_only, xapu_chad, xapu_opus, xapu: 5/5 CTest.
  • Retail 1.0.2.1 boot, 121 s: full time, session d, 1905 presents, 32/32 non-black, no faults. The runtime logs xapu: connected for Opus decoding, 256 streams; packets decoded. RTX 3080 Ti, NVIDIA 616.64, Windows 11.
  • No game data.

Notes

  • The main merge is only for the slot-133 fix; it can be dropped on rebase after #1144 lands.
  • xapu.cpp is the legacy test-only shim; the runtime serves xapu from xapu_queue.cpp (#1144) and chad from xapu_chad.cpp.

AI-assisted.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/2044 **Author:** [@BubsMcgee](https://github.com/BubsMcgee) **Created:** 11/25/2026 **Status:** ✅ Merged **Merged:** 11/26/2026 **Merged by:** [@aslan2142](https://github.com/aslan2142) **Base:** `main` ← **Head:** `rt-xapu-opus` --- ### 📝 Commits (6) - [`9c6cbbc`](https://github.com/ubiquitarianism/leonida/commit/9c6cbbcf12757aa012da8064a6750d482826668a) runtime: xapu.dll as a command queue with the console's layouts, audio silent - [`370e52b`](https://github.com/ubiquitarianism/leonida/commit/370e52b8cbc7dadfaecd3bf00e6fdc919d4244dc) Merge branch 'main' of https://github.com/ubiquitarianism/leonida into xapu-connect-layouts - [`19559fe`](https://github.com/ubiquitarianism/leonida/commit/19559fec600f6e2899a5e96d6a44976ab07f3d65) scripts: build xapu.cpp in the cl.exe fallback (review of #1144) - [`6ee7ef8`](https://github.com/ubiquitarianism/leonida/commit/6ee7ef89b948a9942f5de0b61d1f6756f477d6d5) Merge branch 'main' of https://github.com/ubiquitarianism/leonida into xapu-connect-layouts - [`a5dd540`](https://github.com/ubiquitarianism/leonida/commit/a5dd540bccc6ce20971a6680f076beedc13f2a95) xapu: decode Opus packets through runtime/opus_decoder (RT-XAPU-OPUS-DECODE) - [`4cfbdfc`](https://github.com/ubiquitarianism/leonida/commit/4cfbdfc0b2e39e9137b7f40c48863f1e0e444adc) Merge remote-tracking branch 'origin/main' into rt-xapu-opus-on-1144 ### 📊 Changes **14 files changed** (+1340 additions, -172 deletions) <details> <summary>View changed files</summary> 📝 `docs/audio_hal_exe_calls.md` (+20 -0) 📝 `docs/runtime_imports.md` (+14 -12) 📝 `runtime/CMakeLists.txt` (+72 -1) ➕ `runtime/cmake/opus_decoder.cmake` (+23 -0) ➕ `runtime/opus_decoder/Cargo.lock` (+16 -0) ➕ `runtime/opus_decoder/Cargo.toml` (+16 -0) ➕ `runtime/opus_decoder/README.md` (+33 -0) ➕ `runtime/opus_decoder/leonida_opus_decoder.h` (+44 -0) ➕ `runtime/opus_decoder/src/lib.rs` (+244 -0) 📝 `runtime/shims/xapu_chad.cpp` (+5 -118) ➕ `runtime/shims/xapu_queue.cpp` (+438 -0) 📝 `runtime/test/xapu_chad_test.cpp` (+221 -40) ➕ `runtime/test/xapu_opus_test.cpp` (+193 -0) 📝 `scripts/build_runtime.ps1` (+1 -1) </details> ### 📄 Description Claimed as RT-XAPU-OPUS-DECODE (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7170709281). Depends on: #1144 (RT-XAPU-CONNECT-LAYOUTS). The branch is stacked on #1144 and also merges `main` (`b9320a118`): the #1144 head predates a slot-133 `kernel_writes` fix and crashed early in a retail boot without it. When #1144 lands, this reduces to the decoder alone. ## What and why #1144 keeps the xapu command queue and layouts and leaves `fill_silence()` for a decoder; this wires one in: - `runtime/opus_decoder`: a Rust C-ABI crate over BSD-3-Clause `opus-pure`, built by cargo like `runtime/xma_decoder` (`-DLEONIDA_REQUIRE_OPUS_DECODER=ON` requires it; `-DLEONIDA_OPUS_DECODER_LIB=<path>` links a prebuilt one). - `xapu_queue.cpp::fill()` decodes each process packet into f32 PCM, honouring `first_frame`, `frame_count`, `output_bytes` and the deinterleaved option; without cargo it keeps the table-of-contents frame count and silence. - A decoder is created on activate and destroyed on deactivate/disconnect. The layouts stay #1144's (credited to Marvisak/VIctory `apu.rs`, GPL-3.0-or-later); no VIctory source is copied, and the new files use leonida names. ## Tested - `xapu_opus` (new): 29/29. A generated 440 Hz stereo packet decodes to 960 frames / 0x1E00 bytes with energy; `first_frame` / `frame_count` / `output_bytes` clipping; empty, null and stray-stream errors; deactivate and reactivate. - `xapu_chad` (#1144's): passes unchanged (layouts + silent path). - `acphal`, `acphal_noncached_only`, `xapu_chad`, `xapu_opus`, `xapu`: 5/5 CTest. - Retail 1.0.2.1 boot, 121 s: full time, session `d`, 1905 presents, 32/32 non-black, no faults. The runtime logs `xapu: connected for Opus decoding, 256 streams; packets decoded`. RTX 3080 Ti, NVIDIA 616.64, Windows 11. - No game data. ## Notes - The `main` merge is only for the slot-133 fix; it can be dropped on rebase after #1144 lands. - `xapu.cpp` is the legacy test-only shim; the runtime serves xapu from `xapu_queue.cpp` (#1144) and chad from `xapu_chad.cpp`. AI-assisted. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
4ld0 2026-11-26 21:19:51 +01:00
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
starred/leonida#2050
No description provided.