XAudio2: bound Opus stream count before allocation #1441

Closed
hajduzsolt wants to merge 1 commit from upstream-pr/1451 into main
hajduzsolt commented 2026-11-24 16:18:46 +00:00 (Migrated from github.com)

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


What is in it

  • What is in it
  • Reject Opus multistream counts that cannot fit in the packet before allocating the output vector.
  • Add synthetic tests for impossible counts, including capacity overflow, and a valid two-stream boundary.

Tested

  • Windows 11 Pro x64, AMD Ryzen 7 9800X3D, AMD Radeon RX 9070 XT 16 GB (driver 32.0.32029.2010), Rust 1.98.1 MSVC, debug. - cargo test -p xcl --lib multistream_count_must_fit_the_packet_before_reserving: fails without the guard and passes with it (1 passed, 0 failed). - cargo test --workspace -- --test-threads=4 --nocapture: 771 passed, 0 failed, 41 ignored. Two tests counted as passed reported SKIPPED because the D3D12 debug layer was unavailable: test_title_draws_with_a_root_signature_under_the_debug_layer and uploads_start_from_each_subresources_state.

Regression run

main:

xcl-smoke v1
commit: b7aa9f3bd212088e0d927439284dc5ed325ce3c7
gpu: AMD Radeon RX 9070 XT
title: A newer retail game
seconds: 60
exit: 0x0
frames shown: 1677 (PresentX 1677)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14837 MB

PR:

xcl-smoke v1
commit: 58b4e7568ad94ff3217826846b62e72d7b705e50
gpu: AMD Radeon RX 9070 XT
title: A newer retail game
seconds: 60
exit: 0x0
frames shown: 1675 (PresentX 1675)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14839 MB

Not tested

  • Extended multi-hour gameplay beyond the 60-second smoke run and online Xbox Live features (XCL_NETWORK=0).

AI use

  • GPT-6 wrote the implementation and synthetic unit tests. Human review and smoke verification are pending.
<!-- greyfinch-sync:ivall/xcl:issue:5476015676 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1451). Originally posted by [hajduzsolt](https://github.com/hajduzsolt) on 2026-11-24T16:18:46Z. --- **What is in it** - **What is in it** - Reject Opus multistream counts that cannot fit in the packet before allocating the output vector. - Add synthetic tests for impossible counts, including capacity overflow, and a valid two-stream boundary. **Tested** - Windows 11 Pro x64, AMD Ryzen 7 9800X3D, AMD Radeon RX 9070 XT 16 GB (driver 32.0.32029.2010), Rust 1.98.1 MSVC, debug. - `cargo test -p xcl --lib multistream_count_must_fit_the_packet_before_reserving`: fails without the guard and passes with it (1 passed, 0 failed). - `cargo test --workspace -- --test-threads=4 --nocapture`: 771 passed, 0 failed, 41 ignored. Two tests counted as passed reported SKIPPED because the D3D12 debug layer was unavailable: `test_title_draws_with_a_root_signature_under_the_debug_layer` and `uploads_start_from_each_subresources_state`. **Regression run** main: ``` xcl-smoke v1 commit: b7aa9f3bd212088e0d927439284dc5ed325ce3c7 gpu: AMD Radeon RX 9070 XT title: A newer retail game seconds: 60 exit: 0x0 frames shown: 1677 (PresentX 1677) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14837 MB ``` PR: ``` xcl-smoke v1 commit: 58b4e7568ad94ff3217826846b62e72d7b705e50 gpu: AMD Radeon RX 9070 XT title: A newer retail game seconds: 60 exit: 0x0 frames shown: 1675 (PresentX 1675) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14839 MB ``` **Not tested** - Extended multi-hour gameplay beyond the 60-second smoke run and online Xbox Live features (`XCL_NETWORK=0`). **AI use** - GPT-6 wrote the implementation and synthetic unit tests. Human review and smoke verification are pending.
DavidM1911 commented 2026-11-24 19:07:42 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T18:52:47Z.


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

  • cargo test -p xcl --lib: all passed, 0 failed, ~21 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodified main.)

Thanks!

<!-- greyfinch-sync:ivall/xcl:comment:7141279960 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1451#issuecomment-7141279960). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-24T18:52:47Z. --- Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~21 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodified `main`.) Thanks!
Belox17 commented 2026-11-24 21:09:14 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Belox17 on 2026-11-24T20:03:02Z.


Test report for 58b4e756 on NVIDIA (RTX 3060 Ti): passes on NVIDIA too, and the test fails without the fix

Tested

  • NVIDIA GeForce RTX 3060 Ti 8 GB (32-lane waves), driver 32.0.16.2124; Ryzen 5 5600X; Windows 11 build 26300; rustc 1.98.1 MSVC; DXC 1.8.2502.11 (Windows SDK 10.0.26100); debug build. Head 58b4e756 as is (base b7aa9f3), clean tree.
  • The new test (multistream_count_must_fit_the_packet_before_reserving) with cargo test -p xcl --lib <name>: 1 passed.
  • cargo test --workspace -- --test-threads=4 on the head: 771 passed, 0 failed, 41 ignored; its base b7aa9f3 on the same machine: 770 passed, 0 failed, 41 ignored. SKIPPED on both: gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware (no wave64).
  • Merged into current main c160d86e (clean merge): 859 passed, 0 failed, 42 ignored; main alone: 858 passed, 0 failed, 42 ignored, the same three SKIPPED as above.
  • With the guard in hle/opus.rs reverted (test kept), the test panics with capacity overflow.

Not tested

  • AMD / native wave64 hardware; any retail title (no smoke run).

AI use: Claude Code (Claude Opus 5.5) ran the commands on this machine and wrote this report from those runs.

<!-- greyfinch-sync:ivall/xcl:comment:7142970260 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1451#issuecomment-7142970260). Originally posted by [Belox17](https://github.com/Belox17) on 2026-11-24T20:03:02Z. --- **Test report for `58b4e756` on NVIDIA (RTX 3060 Ti): passes on NVIDIA too, and the test fails without the fix** **Tested** - NVIDIA GeForce RTX 3060 Ti 8 GB (32-lane waves), driver 32.0.16.2124; Ryzen 5 5600X; Windows 11 build 26300; rustc 1.98.1 MSVC; DXC 1.8.2502.11 (Windows SDK 10.0.26100); debug build. Head `58b4e756` as is (base `b7aa9f3`), clean tree. - The new test (`multistream_count_must_fit_the_packet_before_reserving`) with `cargo test -p xcl --lib <name>`: 1 passed. - `cargo test --workspace -- --test-threads=4` on the head: **771 passed, 0 failed, 41 ignored**; its base `b7aa9f3` on the same machine: 770 passed, 0 failed, 41 ignored. SKIPPED on both: `gpu_geometry_wave32_prefix_count_over_a_mask`, `gpu_wave32_program_in_wave64_hardware` (no wave64). - Merged into current `main` `c160d86e` (clean merge): **859 passed, 0 failed, 42 ignored**; `main` alone: 858 passed, 0 failed, 42 ignored, the same three SKIPPED as above. - With the guard in `hle/opus.rs` reverted (test kept), the test panics with `capacity overflow`. **Not tested** - AMD / native wave64 hardware; any retail title (no smoke run). **AI use:** Claude Code (Claude Opus 5.5) ran the commands on this machine and wrote this report from those runs.
upipibi commented 2026-11-26 16:07:55 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by upipibi on 2026-11-26T16:07:55Z.


NVIDIA test report for 58b4e75: RTX 3070 8 GB (Ampere, driver 616.56), Windows 11 26100, Rust 1.100.0, debug. Head tested as-is on its base b7aa9f3.

  • cargo test -p xcl --lib -- --skip hle::xaudio2 --test-threads=4: 714 passed, 0 failed, 21 ignored; 2 SKIPPED (no wave64), not in this PR's files.
  • cargo test -p xcl --lib -- --exact hle::opus::tests::multistream_count_must_fit_the_packet_before_reserving --test-threads=1 --nocapture, 3 runs: 3/3 passed, 0 SKIPPED.
    Lib tests only; no title run.
    AI-assisted (Claude Code, Claude Opus 5.5).
<!-- greyfinch-sync:ivall/xcl:comment:7197223158 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1451#issuecomment-7197223158). Originally posted by [upipibi](https://github.com/upipibi) on 2026-11-26T16:07:55Z. --- NVIDIA test report for `58b4e75`: RTX 3070 8 GB (Ampere, driver 616.56), Windows 11 26100, Rust 1.100.0, debug. Head tested as-is on its base `b7aa9f3`. - `cargo test -p xcl --lib -- --skip hle::xaudio2 --test-threads=4`: 714 passed, 0 failed, 21 ignored; 2 SKIPPED (`no wave64`), not in this PR's files. - `cargo test -p xcl --lib -- --exact hle::opus::tests::multistream_count_must_fit_the_packet_before_reserving --test-threads=1 --nocapture`, 3 runs: 3/3 passed, 0 SKIPPED. Lib tests only; no title run. AI-assisted (Claude Code, Claude Opus 5.5).
Decodere commented 2026-11-27 12:30:30 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Decodere on 2026-11-27T12:30:30Z.


Independent desktop NVIDIA verification of PR #1451 at head 58b4e7568ad94ff3217826846b62e72d7b705e50 (1 commit; exact parent & merge-base: b7aa9f3bd212088e0d927439284dc5ed325ce3c7, pre-#2555 ancestor of main).

Environment

  • GPU: NVIDIA GeForce RTX 4060 (8 GB / 7956 MiB reported by D3D12, Wave32-only Ada), driver 32.0.16.2114 (NVIDIA 621.14, WDDM 3.2)
  • CPU / RAM / OS: Intel Core i5-11400F (6C / 12T), 32 GB RAM (31.9 GiB usable), Windows 11 Home 26200 (Developer Mode off)
  • Toolchain: rustc 1.100.0 (0ef1bc386 2026-11-09) MSVC, DXC 1.9.2609.5, --release

Targeted tests & build (58b4e756)

Command Result
cargo test --release -p xcl --lib multistream_count_must_fit_the_packet_before_reserving -- --nocapture (3 consecutive runs) 1 passed; 0 failed; 0 ignored; 743 filtered out × 3 (0.00s, 0.00s, 0.00s, 0 skipped)
cargo test --release -p xcl --lib hle::opus:: -- --nocapture (3 consecutive runs) 14 passed; 0 failed; 0 ignored; 730 filtered out × 3 (0.00s, 0.00s, 0.00s; 13 executed incl. live Windows Media Foundation MSOpusDecoder, 1 self-skipped on decodes_a_game_sound because XCL_SAMPLE_AWC was unset)
cargo build --release -p xcl Clean build (1m 02s, exit 0, 0 new warnings in opus.rs)

Paired quiet 60 s retail smoke (title: 29640639)

(Note: scripts/smoke.ps1 at b7aa9f3b predates 9683e7a6 and printed the local folder basename on title:; replaced below with the standard 9683e7a6 title hash 29640639, with all measured fields verbatim.)

Exact parent & merge-base (b7aa9f3bd212088e0d927439284dc5ed325ce3c7):

xcl-smoke v1
commit: b7aa9f3bd212088e0d927439284dc5ed325ce3c7
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1598 (PresentX 1599)
presents per 2 s (last 3): 60 61 60
device removals: 0
crashes: 0
peak commit: 14719 MB

PR #1451 (58b4e7568ad94ff3217826846b62e72d7b705e50):

xcl-smoke v1
commit: 58b4e7568ad94ff3217826846b62e72d7b705e50
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1576 (PresentX 1577)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14717 MB

Limits of coverage

  • multistream_count_must_fit_the_packet_before_reserving and 13/14 active hle::opus:: tests (including Windows Media Foundation MSOpusDecoder; 1 test decodes_a_game_sound self-skipped with XCL_SAMPLE_AWC unset) passed 3/3.
  • The 60 s retail smoke confirms steady 60 Hz runtime non-regression (0 device removals, 0 crashes); single-run frame/commit delta vs. parent reflects normal startup variance.

AI disclosure: test execution and report drafting assisted by Google Antigravity (Gemini 4 Neon).

<!-- greyfinch-sync:ivall/xcl:comment:7218324476 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1451#issuecomment-7218324476). Originally posted by [Decodere](https://github.com/Decodere) on 2026-11-27T12:30:30Z. --- Independent desktop NVIDIA verification of **PR #1451** at head `58b4e7568ad94ff3217826846b62e72d7b705e50` (`1` commit; exact parent & merge-base: `b7aa9f3bd212088e0d927439284dc5ed325ce3c7`, pre-`#2555` ancestor of `main`). ### Environment - **GPU:** NVIDIA GeForce RTX 4060 (8 GB / `7956 MiB` reported by D3D12, Wave32-only Ada), driver `32.0.16.2114` (NVIDIA `621.14`, WDDM 3.2) - **CPU / RAM / OS:** Intel Core i5-11400F (6C / 12T), 32 GB RAM (`31.9 GiB` usable), Windows 11 Home `26200` (Developer Mode off) - **Toolchain:** `rustc 1.100.0 (0ef1bc386 2026-11-09)` MSVC, DXC `1.9.2609.5`, `--release` ### Targeted tests & build (`58b4e756`) | Command | Result | | --- | --- | | `cargo test --release -p xcl --lib multistream_count_must_fit_the_packet_before_reserving -- --nocapture` (3 consecutive runs) | `1 passed; 0 failed; 0 ignored; 743 filtered out` × 3 (`0.00s`, `0.00s`, `0.00s`, `0` skipped) | | `cargo test --release -p xcl --lib hle::opus:: -- --nocapture` (3 consecutive runs) | `14 passed; 0 failed; 0 ignored; 730 filtered out` × 3 (`0.00s`, `0.00s`, `0.00s`; `13` executed incl. live Windows Media Foundation `MSOpusDecoder`, `1` self-skipped on `decodes_a_game_sound` because `XCL_SAMPLE_AWC` was unset) | | `cargo build --release -p xcl` | Clean build (`1m 02s`, exit `0`, `0` new warnings in `opus.rs`) | ### Paired quiet 60 s retail smoke (`title: 29640639`) *(Note: `scripts/smoke.ps1` at `b7aa9f3b` predates `9683e7a6` and printed the local folder basename on `title:`; replaced below with the standard `9683e7a6` title hash `29640639`, with all measured fields verbatim.)* Exact parent & merge-base (`b7aa9f3bd212088e0d927439284dc5ed325ce3c7`): ``` xcl-smoke v1 commit: b7aa9f3bd212088e0d927439284dc5ed325ce3c7 gpu: NVIDIA GeForce RTX 4060 title: 29640639 seconds: 60 exit: 0x0 frames shown: 1598 (PresentX 1599) presents per 2 s (last 3): 60 61 60 device removals: 0 crashes: 0 peak commit: 14719 MB ``` PR #1451 (`58b4e7568ad94ff3217826846b62e72d7b705e50`): ``` xcl-smoke v1 commit: 58b4e7568ad94ff3217826846b62e72d7b705e50 gpu: NVIDIA GeForce RTX 4060 title: 29640639 seconds: 60 exit: 0x0 frames shown: 1576 (PresentX 1577) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14717 MB ``` ### Limits of coverage - `multistream_count_must_fit_the_packet_before_reserving` and `13/14` active `hle::opus::` tests (including Windows Media Foundation `MSOpusDecoder`; `1` test `decodes_a_game_sound` self-skipped with `XCL_SAMPLE_AWC` unset) passed `3/3`. - The 60 s retail smoke confirms steady 60 Hz runtime non-regression (`0` device removals, `0` crashes); single-run frame/commit delta vs. parent reflects normal startup variance. *AI disclosure: test execution and report drafting assisted by Google Antigravity (Gemini 4 Neon).*
BBareth commented 2026-11-30 13:11:36 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by BBareth on 2026-11-30T13:11:36Z.


merge-check claim
head: 58b4e7568a

<!-- greyfinch-sync:ivall/xcl:comment:7279487531 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1451#issuecomment-7279487531). Originally posted by [BBareth](https://github.com/BBareth) on 2026-11-30T13:11:36Z. --- merge-check claim head: 58b4e7568ad94ff3217826846b62e72d7b705e50
BBareth commented 2026-11-30 13:22:06 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by BBareth on 2026-11-30T13:22:06Z.


merge-check
base: 9dfbe3ea66
head: 58b4e7568a
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2886 passed, 1 failed, 51 ignored; failing: gpu::dxil::msaa_tests::gpu_direct_image_get_resinfo_d16, which fails on the base alone too (base: 2885 passed, 1 failed, 51 ignored, 28 SKIPPED lines). 28 SKIPPED lines, as on the base. The new test hle::opus::tests::multistream_count_must_fit_the_packet_before_reserving passed, as did the existing multistream tests (5.1 vectors included).
review: no blocking finding; one file, every hunk read. split_multistream_packet now refuses a stream count that cannot fit the packet before it reserves the output vector: each self-delimited stream needs at least two bytes and the last at least one, so the bound is ceil(len / 2), which is what len / 2 + len % 2 computes without overflow. Before, a huge count reached the reservation first. One thing to know: an empty packet with a count of 1 is now None as well (the test pins it); I found no caller of this function in crates/xcl/src outside its tests, so nothing in the tree depends on the old result.
performance: none: one comparison per packet.
verdict: safe to merge
hardware / tool and model: RTX 5070 Ti 16 GB, driver 621.24 (32.0.16.2124); i7-12700K; Windows 11 26200. Claude Code, Claude Fable 5.2 read the diff, ran the build and the suite and wrote this check.

<!-- greyfinch-sync:ivall/xcl:comment:7279743584 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1451#issuecomment-7279743584). Originally posted by [BBareth](https://github.com/BBareth) on 2026-11-30T13:22:06Z. --- merge-check base: 9dfbe3ea6653a9c76ef3ea0d66187a4b5407483b head: 58b4e7568ad94ff3217826846b62e72d7b705e50 merge: clean build: cargo build --workspace -> ok tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2886 passed, 1 failed, 51 ignored; failing: gpu::dxil::msaa_tests::gpu_direct_image_get_resinfo_d16, which fails on the base alone too (base: 2885 passed, 1 failed, 51 ignored, 28 SKIPPED lines). 28 SKIPPED lines, as on the base. The new test `hle::opus::tests::multistream_count_must_fit_the_packet_before_reserving` passed, as did the existing multistream tests (5.1 vectors included). review: no blocking finding; one file, every hunk read. `split_multistream_packet` now refuses a stream count that cannot fit the packet before it reserves the output vector: each self-delimited stream needs at least two bytes and the last at least one, so the bound is ceil(len / 2), which is what `len / 2 + len % 2` computes without overflow. Before, a huge count reached the reservation first. One thing to know: an empty packet with a count of 1 is now `None` as well (the test pins it); I found no caller of this function in `crates/xcl/src` outside its tests, so nothing in the tree depends on the old result. performance: none: one comparison per packet. verdict: safe to merge hardware / tool and model: RTX 5070 Ti 16 GB, driver 621.24 (32.0.16.2124); i7-12700K; Windows 11 26200. Claude Code, Claude Fable 5.2 read the diff, ran the build and the suite and wrote this check.
tiagonleal commented 2026-11-30 14:11:23 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by tiagonleal on 2026-11-30T14:11:23Z.


merge-check
base: 9dfbe3ea66
head: 58b4e7568a
merge: clean, alone and together with #1446 (a7f5d8be) and #1458 (afaca49b): the three heads merged onto the base in one tree (c48c9d04) without conflicts, #1458 included although it edits the same file; also no conflict between that tree and #926 (open, touches opus.rs but not this function)
build: cargo build --workspace -> ok on the combined tree (also cargo build --release -p xcl)
tests: cargo test --workspace --no-fail-fast -j 8 -- --test-threads=4 on the combined tree of the three heads above on the base (one suite run for the three PRs, not one per PR) -> 2888 passed, 1 failed, 51 ignored; SKIPPED: 24 lines, the same as on the base; failing: gpu::dxil::msaa_tests::gpu_direct_image_get_resinfo_d16, which fails the same way on the base alone (2885 passed, 1 failed, 51 ignored; #3513 fixes it). hle::opus::tests::multistream_count_must_fit_the_packet_before_reserving ran and passed. With the guard put back to if stream_count == 0, it fails with "capacity overflow" from the reservation; file restored after.
review: one file, whole diff read. What this adds to the first check: the decode path the emulator uses is split_multistream_into (opus.rs:375, called at opus.rs:1560), and it already refuses a packet shorter than 2 * stream_count - 1 (opus.rs:383). That is the same bound as the new stream_count > len / 2 + len % 2 at opus.rs:408 (for every length, n <= ceil(len / 2) exactly when len >= 2n - 1), so the PR brings the test-only split_multistream_packet in line with the production function; it has no caller outside tests (opus.rs:1691-2318). The bound is the right minimum: each self-delimited stream needs a TOC byte and a length byte, the last stream a TOC byte. The new refusal returns None, which is what the function already returned for every other bad packet. No title can reach it, so nothing a title sends is rejected now that was accepted before.
performance: scripts/smoke.ps1, 60 s of a retail title, release, combined tree of the three heads: 1597 frames and 17767 MB peak commit against 1659 frames and 17322 MB on the base (today's base run after one warm-up; a later traced base run gave 1670 frames, 18142 MB). No device removal, no crash. Audio initialised as on the base: the same acphal and xapu lines, xapu: decoder connected with 256 streams; neither run made an Opus decoder in the menus. I did not rerun to see whether the lower frame count repeats.
verdict: safe to merge
hardware / tool and model: RTX 5070 Ti 16 GB (617.42, wave32), Ryzen 7 9800X3D, 32 GB, Windows 11 26300, rustc 1.100.0 / Claude Code (Claude Opus 5.5 ran the build, suite, tests and smoke, reviewed the diff against the merged source and wrote this)

  • Tiago
<!-- greyfinch-sync:ivall/xcl:comment:7280976007 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1451#issuecomment-7280976007). Originally posted by [tiagonleal](https://github.com/tiagonleal) on 2026-11-30T14:11:23Z. --- merge-check base: 9dfbe3ea6653a9c76ef3ea0d66187a4b5407483b head: 58b4e7568ad94ff3217826846b62e72d7b705e50 merge: clean, alone and together with #1446 (a7f5d8be) and #1458 (afaca49b): the three heads merged onto the base in one tree (c48c9d04) without conflicts, #1458 included although it edits the same file; also no conflict between that tree and #926 (open, touches `opus.rs` but not this function) build: cargo build --workspace -> ok on the combined tree (also `cargo build --release -p xcl`) tests: cargo test --workspace --no-fail-fast -j 8 -- --test-threads=4 on the combined tree of the three heads above on the base (one suite run for the three PRs, not one per PR) -> 2888 passed, 1 failed, 51 ignored; SKIPPED: 24 lines, the same as on the base; failing: `gpu::dxil::msaa_tests::gpu_direct_image_get_resinfo_d16`, which fails the same way on the base alone (2885 passed, 1 failed, 51 ignored; #3513 fixes it). `hle::opus::tests::multistream_count_must_fit_the_packet_before_reserving` ran and passed. With the guard put back to `if stream_count == 0`, it fails with "capacity overflow" from the reservation; file restored after. review: one file, whole diff read. What this adds to the first check: the decode path the emulator uses is `split_multistream_into` (`opus.rs:375`, called at `opus.rs:1560`), and it already refuses a packet shorter than `2 * stream_count - 1` (`opus.rs:383`). That is the same bound as the new `stream_count > len / 2 + len % 2` at `opus.rs:408` (for every length, n <= ceil(len / 2) exactly when len >= 2n - 1), so the PR brings the test-only `split_multistream_packet` in line with the production function; it has no caller outside tests (`opus.rs:1691-2318`). The bound is the right minimum: each self-delimited stream needs a TOC byte and a length byte, the last stream a TOC byte. The new refusal returns `None`, which is what the function already returned for every other bad packet. No title can reach it, so nothing a title sends is rejected now that was accepted before. performance: `scripts/smoke.ps1`, 60 s of a retail title, release, combined tree of the three heads: 1597 frames and 17767 MB peak commit against 1659 frames and 17322 MB on the base (today's base run after one warm-up; a later traced base run gave 1670 frames, 18142 MB). No device removal, no crash. Audio initialised as on the base: the same `acphal` and `xapu` lines, `xapu: decoder connected` with 256 streams; neither run made an Opus decoder in the menus. I did not rerun to see whether the lower frame count repeats. verdict: safe to merge hardware / tool and model: RTX 5070 Ti 16 GB (617.42, wave32), Ryzen 7 9800X3D, 32 GB, Windows 11 26300, rustc 1.100.0 / Claude Code (Claude Opus 5.5 ran the build, suite, tests and smoke, reviewed the diff against the merged source and wrote this) - Tiago
Foniass commented 2026-12-01 05:48:15 +00:00 (Migrated from github.com)

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


Triage (#1607) – head 58b4e75

main commit 01fad57 ("XAudio2: reuse validated Opus multistream scratch") added split_multistream_into, which rejects packet.len() < stream_count * 2 - 1. That is the same bound this PR adds, and the decoder (opus.rs, the split_multistream_into(packet, stream_count, &mut self.sub_pkts) call) uses only it now.
split_multistream_packet, the function this PR changes, has no callers outside opus.rs's tests on main. The stream count comes from the OpusHead u8, so its allocation was at most 255 entries anyway. #2696 adds the same bound in its own rewrite.
Recommendation: close (superseded by main commit 01fad57).

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:7302154633 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1451#issuecomment-7302154633). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T05:48:15Z. --- **Triage (#1607)** – head 58b4e75 `main` commit 01fad57 ("XAudio2: reuse validated Opus multistream scratch") added `split_multistream_into`, which rejects `packet.len() < stream_count * 2 - 1`. That is the same bound this PR adds, and the decoder (`opus.rs`, the `split_multistream_into(packet, stream_count, &mut self.sub_pkts)` call) uses only it now. `split_multistream_packet`, the function this PR changes, has no callers outside `opus.rs`'s tests on `main`. The stream count comes from the `OpusHead` `u8`, so its allocation was at most 255 entries anyway. #2696 adds the same bound in its own rewrite. Recommendation: close (superseded by main commit 01fad57). AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
throny commented 2026-12-01 12:46:08 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by throny on 2026-12-01T12:46:08Z.


Closing as superseded: this change is already on main (01fad57f). main decoder uses split_multistream_into with bound packet.len() >= 2*count-1; split_multistream_packet (the PR's target) is only called from tests in opus.rs and has no non-test caller

Two independent checks found this: Foniass's close list on #1607 and ours against current main. If something here is still missing on main, say so and reopen it, or ask and I will.

AI use: Claude Code (Claude Opus 5.5); the per-PR comparison was done by Claude Sonnet 5.5 sub-agents.

<!-- greyfinch-sync:ivall/xcl:comment:7311618373 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1451#issuecomment-7311618373). Originally posted by [throny](https://github.com/throny) on 2026-12-01T12:46:08Z. --- Closing as superseded: this change is already on `main` (01fad57f). main decoder uses split_multistream_into with bound packet.len() >= 2*count-1; split_multistream_packet (the PR's target) is only called from tests in opus.rs and has no non-test caller Two independent checks found this: Foniass's close list on #1607 and ours against current `main`. If something here is still missing on `main`, say so and reopen it, or ask and I will. AI use: Claude Code (Claude Opus 5.5); the per-PR comparison was done by Claude Sonnet 5.5 sub-agents.

Pull request closed

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!1441
No description provided.