Tests: xapu decodes a title's Opus packets into its output buffer (#294) #1273

Open
ersinhf wants to merge 1 commit from upstream-pr/1283 into main
ersinhf commented 2026-11-24 14:16:25 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by ersinhf on 2026-11-24T14:16:25Z.


#294 made the console decoder (xapu) decode the Opus packets a title sends, but no test reaches that path: acphal's tests only cover a Process without an Activate (silence). This adds an integration test that drives the exports the way a title does, so it needs no change to crates/xcl/src. Follow-up to #294 (its author asked for these tests there).

What is in it

  • crates/xcl/tests/xapu_opus.rs (new, one commit): XApuConnect, XApuEnqueueCommand with the commands written as bytes at the retail title's offsets (Activate: channels at +24, 48000 at +56; Process: one raw Opus packet and a float output buffer), XApuDequeueResult. The packets are the repo's 440 Hz libopus ones (MONO_HYBRID_20MS in opus.rs). Two tests:
    • xapu_decodes_the_titles_opus_packets_into_its_buffer: Activate (mono), 25 Process with first_frame 312 on the first → 648 frames, then 960 each; nothing left past the frames written; the 440 Hz tone (Goertzel, as opus.rs measures it); xapu_decode_errors unchanged; silence after Deactivate; a second Activate (the decoder is reset, not rebuilt) gives the same samples as the first decoder
    • xapu_writes_unaligned_buffers_and_ignores_unknown_streams: an output buffer one byte off a 4-byte boundary is decoded into and nothing outside it is written; a stream the connection does not have gets silence and leaves stream 0 decoding in sequence
  • Both return early (skipping: no Opus decoder) when opus::is_available() is false, like the opus.rs tests. The xapu_packets_decoded check is >= because the counters are global and the two tests run in parallel.

Tested

  • NVIDIA GeForce RTX 4070 (Ada), driver 621.14 (32.0.16.2114); AMD Ryzen 5 7500F, 32 GB; Windows 11 build 26200; rustc 1.100.0 stable-x86_64-pc-windows-msvc; DXC 1.9.2602.17 (SDK 10.0.26100.0); no XCL_SAMPLE_* set; Opus through Windows' MSOpusDecoder
  • On 930e8b4 plus this test: cargo build --workspace, then cargo test --workspace --no-fail-fast -- --test-threads=4 (debug): 753 passed, 0 failed, 41 ignored; the same in release (--release): 753 passed, 0 failed, 41 ignored
  • SKIPPED (no wave64): gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware
  • The test fails without #294: on 29fb6b7 (the commit before it, where xapu answered silence; the two xaudio2::stats() checks taken out because those counters came with #294) both tests fail – first_frame (the pre-skip) is left out (960 frames, 648 expected) and decoded into the unaligned buffer

Regression run

  • Not needed: the PR changes only crates/xcl/tests/.

Not tested

  • libopus (opus.dll, the Wine path): only Windows' decoder was used here
  • stereo xapu streams, packets longer than 20 ms
  • a retail title (not needed for a test-only change; no game here)

AI use

  • Claude Code with Claude Opus 5.5 wrote the test, ran the builds and the suites on this machine and wrote this description; the person opening the PR read the test and checked each point.

🤖 Generated with Claude Code

<!-- greyfinch-sync:ivall/xcl:issue:5473863728 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1283). Originally posted by [ersinhf](https://github.com/ersinhf) on 2026-11-24T14:16:25Z. --- #294 made the console decoder (xapu) decode the Opus packets a title sends, but no test reaches that path: `acphal`'s tests only cover a Process without an Activate (silence). This adds an integration test that drives the exports the way a title does, so it needs no change to `crates/xcl/src`. Follow-up to #294 (its author asked for these tests there). **What is in it** - `crates/xcl/tests/xapu_opus.rs` (new, one commit): `XApuConnect`, `XApuEnqueueCommand` with the commands written as bytes at the retail title's offsets (Activate: channels at +24, 48000 at +56; Process: one raw Opus packet and a float output buffer), `XApuDequeueResult`. The packets are the repo's 440 Hz libopus ones (`MONO_HYBRID_20MS` in `opus.rs`). Two tests: - `xapu_decodes_the_titles_opus_packets_into_its_buffer`: Activate (mono), 25 Process with `first_frame` 312 on the first → 648 frames, then 960 each; nothing left past the frames written; the 440 Hz tone (Goertzel, as `opus.rs` measures it); `xapu_decode_errors` unchanged; silence after Deactivate; a second Activate (the decoder is reset, not rebuilt) gives the same samples as the first decoder - `xapu_writes_unaligned_buffers_and_ignores_unknown_streams`: an output buffer one byte off a 4-byte boundary is decoded into and nothing outside it is written; a stream the connection does not have gets silence and leaves stream 0 decoding in sequence - Both return early (`skipping: no Opus decoder`) when `opus::is_available()` is false, like the `opus.rs` tests. The `xapu_packets_decoded` check is `>=` because the counters are global and the two tests run in parallel. **Tested** - NVIDIA GeForce RTX 4070 (Ada), driver 621.14 (32.0.16.2114); AMD Ryzen 5 7500F, 32 GB; Windows 11 build 26200; rustc 1.100.0 `stable-x86_64-pc-windows-msvc`; DXC 1.9.2602.17 (SDK 10.0.26100.0); no `XCL_SAMPLE_*` set; Opus through Windows' MSOpusDecoder - On `930e8b4` plus this test: `cargo build --workspace`, then `cargo test --workspace --no-fail-fast -- --test-threads=4` (debug): **753 passed, 0 failed, 41 ignored**; the same in release (`--release`): **753 passed, 0 failed, 41 ignored** - SKIPPED (no wave64): `gpu_geometry_wave32_prefix_count_over_a_mask`, `gpu_wave32_program_in_wave64_hardware` - The test fails without #294: on `29fb6b7` (the commit before it, where xapu answered silence; the two `xaudio2::stats()` checks taken out because those counters came with #294) both tests fail – `first_frame (the pre-skip) is left out` (960 frames, 648 expected) and `decoded into the unaligned buffer` **Regression run** - Not needed: the PR changes only `crates/xcl/tests/`. **Not tested** - libopus (`opus.dll`, the Wine path): only Windows' decoder was used here - stereo xapu streams, packets longer than 20 ms - a retail title (not needed for a test-only change; no game here) **AI use** - Claude Code with Claude Opus 5.5 wrote the test, ran the builds and the suites on this machine and wrote this description; the person opening the PR read the test and checked each point. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
DavidM1911 commented 2026-11-24 15:05:48 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T14:18:44Z.


Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --test xapu_opus: 2 passed, 0 failed.

Thanks!

<!-- greyfinch-sync:ivall/xcl:comment:7134170176 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/1283#issuecomment-7134170176). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-24T14:18:44Z. --- Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --test xapu_opus`: 2 passed, 0 failed. Thanks!
thehollowedone commented 2026-11-24 15:05:50 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by thehollowedone on 2026-11-24T14:22:13Z.


Independent stereo XApu check on c529525, Windows 11 build 26300, Ryzen 7 9800X3D, Rust 1.99.1 MSVC, debug. XCL selected Windows’ MSOpusDecoder.

I fed the five in-tree stereo CELT packets through the PR’s XApu command helpers. The first packet returned 648 frames after the 312-frame pre-skip and the remaining packets returned 960 each. The decoded left channel favored 440 Hz over 880 Hz by 212×, and the right favored 880 Hz over 440 Hz by 109×, using the same Goertzel measurement as the mono fixture. The output guards stayed intact, the unused tail was silent, and reactivation produced identical PCM. All ten packets across the two passes decoded with zero errors.

Both stock tests and the added stereo check passed with zero skips. Synthetic audio only. AI-assisted. Codex (GPT-6, exact variant unavailable) wrote and ran the scratch fixture and drafted this report.

<!-- greyfinch-sync:ivall/xcl:comment:7134262650 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/1283#issuecomment-7134262650). Originally posted by [thehollowedone](https://github.com/thehollowedone) on 2026-11-24T14:22:13Z. --- Independent stereo XApu check on [`c529525`](https://github.com/ivall/xcl/commit/c529525813032d2dcfdd3da26bb06774204cddcd), Windows 11 build 26300, Ryzen 7 9800X3D, Rust 1.99.1 MSVC, debug. XCL selected Windows’ `MSOpusDecoder`. I fed the five in-tree stereo CELT packets through the PR’s XApu command helpers. The first packet returned 648 frames after the 312-frame pre-skip and the remaining packets returned 960 each. The decoded left channel favored 440 Hz over 880 Hz by 212×, and the right favored 880 Hz over 440 Hz by 109×, using the same Goertzel measurement as the mono fixture. The output guards stayed intact, the unused tail was silent, and reactivation produced identical PCM. All ten packets across the two passes decoded with zero errors. Both stock tests and the added stereo check passed with zero skips. Synthetic audio only. AI-assisted. Codex (GPT-6, exact variant unavailable) wrote and ran the scratch fixture and drafted this report.
DavidM1911 commented 2026-11-24 16:07:27 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T16:04:18Z.


Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib -- --test-threads=1: all passed, 0 failed, 21 ignored.

Thanks!

<!-- greyfinch-sync:ivall/xcl:comment:7137071442 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/1283#issuecomment-7137071442). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-24T16:04:18Z. --- Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib -- --test-threads=1`: all passed, 0 failed, 21 ignored. Thanks!
github-actions[bot] commented 2026-11-28 08:00:30 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-11-28T08:00:30Z.


Nothing has happened on this PR for 3 days, so it is marked stale and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto main if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.

<!-- greyfinch-sync:ivall/xcl:comment:7236301099 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1283#issuecomment-7236301099). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-11-28T08:00:30Z. --- Nothing has happened on this PR for 3 days, so it is marked `stale` and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto `main` if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.
Foniass commented 2026-12-01 05:19:40 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T05:19:40Z.


Triage (#1607) – head c529525

No open or merged PR makes the same change. The decoder from #294 is on main (hle/acphal.rs decode_into), and this PR adds the only integration test of it through the exported XApu* calls.
No problems found in the diff. The byte offsets written by process and control match the packed XApuProcess / XApuActivate on main. The expectations also match main's XApuEnqueueCommand: the pre-skip, silence after Deactivate, a reset rather than rebuilt decoder on the same layout, and an unknown stream answered with stream 0's channel count.
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

<!-- greyfinch-sync:ivall/xcl:comment:7301654169 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1283#issuecomment-7301654169). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T05:19:40Z. --- **Triage (#1607)** – head c529525 No open or merged PR makes the same change. The decoder from #294 is on main (hle/acphal.rs `decode_into`), and this PR adds the only integration test of it through the exported XApu* calls. No problems found in the diff. The byte offsets written by `process` and `control` match the packed `XApuProcess` / `XApuActivate` on main. The expectations also match main's `XApuEnqueueCommand`: the pre-skip, silence after Deactivate, a reset rather than rebuilt decoder on the same layout, and an unknown stream answered with stream 0's channel count. Recommendation: keep open. AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/1283:upstream-pr/1283'
git switch 'upstream-pr/1283'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/1283'
git switch 'upstream-pr/1283'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1283'
git switch 'upstream-pr/1283'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1283'
git switch 'main'
git merge --squash 'upstream-pr/1283'
git switch 'main'
git merge --ff-only 'upstream-pr/1283'
git switch 'main'
git merge 'upstream-pr/1283'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
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.

Reference
xcl-dev/xcl!1273
No description provided.