Skip to content

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

Closed
ufoptg wants to merge 1 commit into
mainfrom
upstream-pr/926
Closed

ufoptg wants to merge 1 commit into
mainfrom
upstream-pr/926

Conversation

@ufoptg

@ufoptg ufoptg commented Nov 24, 2026

Copy link
Copy Markdown
Owner

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 (GTA VI 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: GTA6.Xbox.v1.0.2.1-CYBERLEEK
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: GTA6.Xbox.v1.0.2.1-CYBERLEEK
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.

Mirror of xcl-dev#926 (auto-synced, do not edit).

…p stream-change retries

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.
@ufoptg

ufoptg commented Nov 25, 2026

Copy link
Copy Markdown
Owner Author

Upstream PR xcl-dev#926 was closed or merged.

@ufoptg ufoptg closed this Nov 25, 2026
@ufoptg
ufoptg deleted the upstream-pr/926 branch November 25, 2026 00:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants