From a5dd540bccc6ce20971a6680f076beedc13f2a95 Mon Sep 17 00:00:00 2001 From: BubsMcgee Date: Wed, 25 Nov 2026 14:11:53 -0500 Subject: xapu: decode Opus packets through runtime/opus_decoder (RT-XAPU-OPUS-DECODE) Builds on #1144 (RT-XAPU-CONNECT-LAYOUTS): the queue and layouts stay there; fill() decodes each process packet through a Rust C-ABI crate over BSD-3 opus-pure when cargo builds it, and keeps the table-of-contents silence path otherwise. Adds xapu_opus_test (a generated 440 Hz stereo packet decoded to 960 frames) and the CMake wiring; xapu_chad_test keeps covering the layouts and the silent path. No game data. --- runtime/opus_decoder/README.md | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 runtime/opus_decoder/README.md (limited to 'runtime/opus_decoder/README.md') diff --git a/runtime/opus_decoder/README.md b/runtime/opus_decoder/README.md new file mode 100644 index 000000000..2b516e496 --- /dev/null +++ b/runtime/opus_decoder/README.md @@ -0,0 +1,33 @@ +# Opus decoder C ABI + +This crate exposes a C ABI around the BSD-3-Clause `opus-pure` package for the console audio +decoder (`xapu.dll`). The command protocol lives in `runtime/shims/xapu_chad.cpp`; this crate only +decodes one Opus packet into interleaved f32 PCM, resets the decoder, and (for tests) encodes a +synthetic tone. + +## Build + +```sh +cargo fmt --manifest-path runtime/opus_decoder/Cargo.toml -- --check +cargo test --manifest-path runtime/opus_decoder/Cargo.toml --locked +cargo build --release --manifest-path runtime/opus_decoder/Cargo.toml --locked +``` + +`runtime/CMakeLists.txt` builds this crate for `x86_64-pc-windows-msvc` at configure time when +`cargo` is on `PATH` and links it into `gta6rt` and `xapu_chad_test` with +`LEONIDA_HAVE_OPUS_DECODER` defined. The first build fetches `opus-pure` from crates.io. Set +`CARGO_NET_OFFLINE=true` for a configure that uses only the local Cargo cache. + +Without `cargo`, when the build fails, or with the `cl.exe` fallback of `scripts/build_runtime.ps1`, +the XAPU path stays silent. Use `-DLEONIDA_REQUIRE_OPUS_DECODER=ON` to require the decoder in a +CMake build. + +To link an already-built `leonida_opus_decoder.lib` without invoking `cargo` during CMake +configure, pass `-DLEONIDA_OPUS_DECODER_LIB=`. + +## Facts and credit + +The `xapu.dll` command protocol (connect input/output, per-stream command budget, activate / +process / reset / deactivate, result order) follows Marvisak/VIctory +`crates/victory-hle/src/modules/apu.rs` (GPL-3.0-or-later), which this repository already credits for +other modules. `opus-pure` is BSD-3-Clause and stays a dependency; no code from it is copied. -- cgit v1.2.3