Opus: only take MFT output types with the decoder's channel count, cap stream-change retries #926

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

@⁠DavidM1911 on GitHub · 2026-11-24 08:29 UTC · original
DavidM1911:opus-mft-guards → main · +10 −0 · 1 files · 1 commits · open

Part of #327 (item 3).

Two guards on the Media Foundation MFT path in crates/xcl/src/hle/opus.rs:

  • MftDecoder::configure_output accepted the first PCM16/Float32 output type without checking MF_MT_AUDIO_NUM_CHANNELS against the decoder's channel count, then overwrote self.channels — a multistream interleave sized for the expected count could index past the buffer if the MFT enumerated a different count first. Output types whose channel count differs are now skipped; a missing NUM_CHANNELS still defaults to the decoder's count as before.
  • MftDecoder::drain_output retried MF_E_TRANSFORM_STREAM_CHANGE in an unbounded loop; it now gives up after 4 reconfigurations.

What is in it

  • crates/xcl/src/hle/opus.rs only. No new unit test: both paths need a live IMFTransform, which the crate's tests do not mock; the existing Opus/MFT tests still pass.

Tested

  • Windows 11, Ryzen 9 7900X (Radeon iGPU + NVIDIA RTX 3060 Ti 8 GB, driver 610.88), Rust 1.100.0 x86_64-pc-windows-msvc:
    • cargo test -p xcl --lib opus: 15 passed, 0 failed
    • cargo test --workspace -- --test-threads=4: 676 passed, 0 failed, 41 ignored
  • Regression run on the retail title (1.0.2.1, own copy), RTX 3060 Ti, scripts/smoke.ps1 -Seconds 60, cargo build --release -p xcl:

main a6f5f7a (same baseline as the sibling PRs; upstream/main is now 2997c9a, docs-only on top):

xcl-smoke v1
commit: a6f5f7a74cc620c1f88a9e3669a633d10c3c8212
gpu: NVIDIA GeForce RTX 3060 Ti
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 1503 (PresentX 1503)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14437 MB

this PR's head 8d0176d:

xcl-smoke v1
commit: 8d0176d9b8099092d2c9809bf25630be68e7d7ee
gpu: NVIDIA GeForce RTX 3060 Ti
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 1468 (PresentX 1468)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14455 MB

Not tested

  • A real MFT that enumerates mismatched channel counts or loops on STREAM_CHANGE (needs a misbehaving decoder); Linux/macOS (crate is Windows-only)

AI use

  • Devin (SWE-2 Flash Medium): implemented the guards, ran the suites and smoke runs.
**@⁠DavidM1911** on GitHub · 2026-11-24 08:29 UTC · [original](https://github.com/xcl-dev/xcl/pull/926) `DavidM1911:opus-mft-guards` → `main` · +10 −0 · 1 files · 1 commits · open Part of #327 (item 3). Two guards on the Media Foundation MFT path in `crates/xcl/src/hle/opus.rs`: - `MftDecoder::configure_output` accepted the first PCM16/Float32 output type without checking `MF_MT_AUDIO_NUM_CHANNELS` against the decoder's channel count, then overwrote `self.channels` — a multistream interleave sized for the expected count could index past the buffer if the MFT enumerated a different count first. Output types whose channel count differs are now skipped; a missing `NUM_CHANNELS` still defaults to the decoder's count as before. - `MftDecoder::drain_output` retried `MF_E_TRANSFORM_STREAM_CHANGE` in an unbounded loop; it now gives up after 4 reconfigurations. **What is in it** - `crates/xcl/src/hle/opus.rs` only. No new unit test: both paths need a live `IMFTransform`, which the crate's tests do not mock; the existing Opus/MFT tests still pass. **Tested** - Windows 11, Ryzen 9 7900X (Radeon iGPU + NVIDIA RTX 3060 Ti 8 GB, driver 610.88), Rust 1.100.0 `x86_64-pc-windows-msvc`: - `cargo test -p xcl --lib opus`: 15 passed, 0 failed - `cargo test --workspace -- --test-threads=4`: 676 passed, 0 failed, 41 ignored - Regression run on the retail title (1.0.2.1, own copy), RTX 3060 Ti, `scripts/smoke.ps1 -Seconds 60`, `cargo build --release -p xcl`: main `a6f5f7a` (same baseline as the sibling PRs; upstream/main is now `2997c9a`, docs-only on top): ``` xcl-smoke v1 commit: a6f5f7a74cc620c1f88a9e3669a633d10c3c8212 gpu: NVIDIA GeForce RTX 3060 Ti title: 3c290c16 seconds: 60 exit: 0x0 frames shown: 1503 (PresentX 1503) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14437 MB ``` this PR's head `8d0176d`: ``` xcl-smoke v1 commit: 8d0176d9b8099092d2c9809bf25630be68e7d7ee gpu: NVIDIA GeForce RTX 3060 Ti title: 3c290c16 seconds: 60 exit: 0x0 frames shown: 1468 (PresentX 1468) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14455 MB ``` **Not tested** - A real MFT that enumerates mismatched channel counts or loops on STREAM_CHANGE (needs a misbehaving decoder); Linux/macOS (crate is Windows-only) **AI use** - Devin (SWE-2 Flash Medium): implemented the guards, ran the suites and smoke runs.
configure_output accepted the first PCM16/Float32 type regardless of MF_MT_AUDIO_NUM_CHANNELS and then overwrote self.channels, so a multistream interleave could index past the buffer; drain_output retried MF_E_TRANSFORM_STREAM_CHANGE forever. Output types whose channel count differs from the decoder's are now skipped, and more than 4 stream changes is an error.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:37:06 +00:00
Author
Owner

@⁠SlopTart on GitHub · 2026-11-24 10:37 UTC · original

Linux / AMD RDNA3 datapoint.

Merged state: head 8d0176d onto main 9aec53d, clean merge.

Full suite, cargo test --workspace --release --no-fail-fast --target x86_64-pc-windows-gnu -- --test-threads=4: 717 passed, 7 failed, 41 ignored; failures are the known Wine-lane set from my #42 rows. Opus MFT output-type gating green.

Not tested: retail titles (none here), Windows, RDNA4.
Counts only, no game data.

Machine: RX 7900 XT (RADV NAVI31), Mesa 26.2.5, kernel 7.2 (Arch), Proton Experimental (wine-11.0), patched vkd3d-proton v3.1, Rust cross x86_64-pc-windows-gnu, XCL_NETWORK=0, release profile, --test-threads=4. My Linux rows: #42 / #718.

AI use: Hermes agent (local Qwen-class) ran the suite and drafted this; I checked it before posting.

**@⁠SlopTart** on GitHub · 2026-11-24 10:37 UTC · [original](https://github.com/xcl-dev/xcl/pull/926#issuecomment-7129029815) Linux / AMD RDNA3 datapoint. **Merged state:** head `8d0176d` onto main `9aec53d`, clean merge. **Full suite, `cargo test --workspace --release --no-fail-fast --target x86_64-pc-windows-gnu -- --test-threads=4`:** **717 passed, 7 failed, 41 ignored**; failures are the known Wine-lane set from my #42 rows. Opus MFT output-type gating green. **Not tested:** retail titles (none here), Windows, RDNA4. Counts only, no game data. **Machine:** RX 7900 XT (RADV NAVI31), Mesa 26.2.5, kernel 7.2 (Arch), Proton Experimental (wine-11.0), patched vkd3d-proton v3.1, Rust cross `x86_64-pc-windows-gnu`, `XCL_NETWORK=0`, release profile, `--test-threads=4`. My Linux rows: #42 / #718. AI use: Hermes agent (local Qwen-class) ran the suite and drafted this; I checked it before posting.
Author
Owner

@⁠throny on GitHub · 2026-11-25 10:16 UTC · original

Two contributors checked independently and found that #503 solves the same problem (for #327) in a different way: #1607, group D12. You may want to compare them with the other author and agree on one, or say in the PR why both are needed.

This is a hint from the community triage in #1607, not a maintainer decision.

AI use: Claude Code (Claude Opus 5.5), posted by a script from the #1607 table.

**@⁠throny** on GitHub · 2026-11-25 10:16 UTC · [original](https://github.com/xcl-dev/xcl/pull/926#issuecomment-7159475267) <!-- xcl-1607-hint:D12 --> Two contributors checked independently and found that #503 solves the same problem (for #327) in a different way: #1607, group D12. You may want to compare them with the other author and agree on one, or say in the PR why both are needed. This is a hint from the community triage in #1607, not a maintainer decision. AI use: Claude Code (Claude Opus 5.5), posted by a script from the #1607 table.
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/926/head:github-bot/gh-926'
git switch 'github-bot/gh-926'

Merge

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