feat(hle): add XMA2 overlap carry/resume, ApuHeapGetState, and APU PCM/Opus pitch conversion #629

Open
github-bot wants to merge 1 commit from github-bot/gh-629 into main AGit
Owner

@⁠chefulano on GitHub · 2026-12-05 20:27 UTC · original
chefulano:feat/xma2-carry-opus-pcm-resampler → main · +667 −48 · 3 files · 1 commits · open

Titles chaining XMA2 contexts across voice handoffs or connecting to xapu.dll for sample-rate/pitch conversion (DECODE_CONVERT_OPUS, CONVERT_PCM) or querying APU heap occupancy (ApuHeapGetState) previously hit missing overlap state, unimplemented processing kinds (E_NOTIMPL), or missing heap accounting.

This PR ports the audio/APU improvements from gamingwithhomie/larp (1250552) cleanly onto main:

  • XMA2 overlap carry/resume & audio heap (crates/victory-formats/src/xma.rs, crates/victory-hle/src/modules/audio.rs): adds xma::Carry + Decoder::carry() / Decoder::resume() for chaining XMA2 overlap across contexts, refill recovery when contexts resume, and ApuHeapGetState tracking cached vs non-cached allocations.
  • APU Opus/PCM pitch conversion (crates/victory-hle/src/modules/apu.rs): implements DECODE_CONVERT_OPUS and CONVERT_PCM with linear pitch resampling (0.125..=8.0 with per-frame ramp), FLUSH / RESET_DECODER / DEINTERLEAVED_INPUT handling, and OUTPUT_READY / NEED_MORE_INPUT / MORE_OUTPUT_AVAILABLE state reporting on main's synchronous APU path.

Queue check

  • Independent of #175 and #455 (the async APU worker PRs): this PR keeps main's synchronous XApuEnqueueCommand execution model so it carries no unmerged dependencies and can merge in either order. Also cleanly compatible with #508 (merged Opus PCM scratch reuse).

Checks

  • cargo xtask policy — pass (368 files ok)
  • cargo test -p xtask — 11/11 passed
  • cargo test -p victory-formats -- xma (native Linux) — 20/20 passed, 5 ignored (includes new carry_and_resume_round_trip_and_validate_inputs)
  • cargo check --locked --release --target x86_64-pc-windows-msvc -p victory-formats -p victory-hle -p victory --tests — pass
  • cargo clippy --no-deps --locked --release --target x86_64-pc-windows-msvc -p victory-formats -p victory-hle --all-targets — 0 new warnings
  • PKG=victory-hle ./build.sh test --lib -- modules::audio:: — 9/9 passed (includes new heap_state_counts_each_heap)
  • PKG=victory-hle ./build.sh test --lib -- modules::apu:: — 3/3 passed (includes new convert_pcm_and_decode_convert_opus_resample_and_flush)
  • Cost: no runtime overhead on existing DECODE_OPUS connections (converter: None); new conversion paths activate only when a title connects with DECODE_CONVERT_OPUS or CONVERT_PCM.

Created with Gemini 4 Neon in T3 Code.

**@⁠chefulano** on GitHub · 2026-12-05 20:27 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/629) `chefulano:feat/xma2-carry-opus-pcm-resampler` → `main` · +667 −48 · 3 files · 1 commits · open Titles chaining XMA2 contexts across voice handoffs or connecting to `xapu.dll` for sample-rate/pitch conversion (`DECODE_CONVERT_OPUS`, `CONVERT_PCM`) or querying APU heap occupancy (`ApuHeapGetState`) previously hit missing overlap state, unimplemented processing kinds (`E_NOTIMPL`), or missing heap accounting. This PR ports the audio/APU improvements from `gamingwithhomie/larp` (`1250552`) cleanly onto `main`: - **XMA2 overlap carry/resume & audio heap (`crates/victory-formats/src/xma.rs`, `crates/victory-hle/src/modules/audio.rs`):** adds `xma::Carry` + `Decoder::carry()` / `Decoder::resume()` for chaining XMA2 overlap across contexts, refill recovery when contexts resume, and `ApuHeapGetState` tracking cached vs non-cached allocations. - **APU Opus/PCM pitch conversion (`crates/victory-hle/src/modules/apu.rs`):** implements `DECODE_CONVERT_OPUS` and `CONVERT_PCM` with linear pitch resampling (`0.125..=8.0` with per-frame ramp), `FLUSH` / `RESET_DECODER` / `DEINTERLEAVED_INPUT` handling, and `OUTPUT_READY` / `NEED_MORE_INPUT` / `MORE_OUTPUT_AVAILABLE` state reporting on `main`'s synchronous APU path. ### Queue check - Independent of #175 and #455 (the async APU worker PRs): this PR keeps `main`'s synchronous `XApuEnqueueCommand` execution model so it carries no unmerged dependencies and can merge in either order. Also cleanly compatible with #508 (merged Opus PCM scratch reuse). ### Checks - `cargo xtask policy` — pass (`368 files ok`) - `cargo test -p xtask` — 11/11 passed - `cargo test -p victory-formats -- xma` (native Linux) — 20/20 passed, 5 ignored (includes new `carry_and_resume_round_trip_and_validate_inputs`) - `cargo check --locked --release --target x86_64-pc-windows-msvc -p victory-formats -p victory-hle -p victory --tests` — pass - `cargo clippy --no-deps --locked --release --target x86_64-pc-windows-msvc -p victory-formats -p victory-hle --all-targets` — 0 new warnings - `PKG=victory-hle ./build.sh test --lib -- modules::audio::` — 9/9 passed (includes new `heap_state_counts_each_heap`) - `PKG=victory-hle ./build.sh test --lib -- modules::apu::` — 3/3 passed (includes new `convert_pcm_and_decode_convert_opus_resample_and_flush`) - Cost: no runtime overhead on existing `DECODE_OPUS` connections (`converter: None`); new conversion paths activate only when a title connects with `DECODE_CONVERT_OPUS` or `CONVERT_PCM`. Created with Gemini 4 Neon in T3 Code.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-05 20:30:56 +00:00
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/629/head:github-bot/gh-629'
git switch 'github-bot/gh-629'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-629'
git switch 'github-bot/gh-629'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-629'
git switch 'github-bot/gh-629'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-629'
git switch 'main'
git merge --squash 'github-bot/gh-629'
git switch 'main'
git merge --ff-only 'github-bot/gh-629'
git switch 'main'
git merge 'github-bot/gh-629'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.