Audio: a silent playback endpoint when the host has no render device #929

Open
github-bot wants to merge 3 commits from github-bot/gh-929 into main AGit
Owner

@⁠vladbondarenko97 on GitHub · 2026-11-24 14:17 UTC · original
vladbondarenko97:audio/silent-endpoint → main · +813 −4 · 4 files · 3 commits · open

With no active Windows playback device, the title's audio output setup never allocates its buffers and returns while still holding a lock. The audio thread then never drains the per-thread 96 KiB command streams, and about 20–30 s in the title's audio-thread assert fires (its own int3). This is the trap in #834, and the Wine/no-sound-driver case #222 warns about. The chain is diagnosed with RVAs in ivall/xcl#695. A console always has an output, so the title has no path for this.

What is in it

  • modules/audio/silent.rs overrides the title's CoCreateInstance (ole32.dll, api-ms-win-core-com-l1-*; the retail exe imports it from api-ms-win-core-com-l1-1-0.dll and has no CoCreateInstanceEx/CoGetClassObject import). The host call always runs first. Only a successful MMDeviceEnumerator/IMMDeviceEnumerator creation without aggregation is looked at.
  • If the host has an ACTIVE render endpoint (or counting fails), the native enumerator is returned untouched, so PCs with audio see no change. Otherwise render flow shows one silent ACTIVE device; capture flow, other GetDevice ids and notifications go to the host.
  • The silent device's ISpatialAudioClient accepts 48 kHz float. Its ISpatialAudioObjectRenderStream signals the title's event every 10 ms while started, hands out 480-frame buffers and discards them. Start/Stop/Reset can be repeated, and dynamic objects are counted and capped. One info line is logged when it is used.
  • windows/windows-core become plain cfg(windows) dependencies (they were diagnostics-only).
  • Implemented independently, following the behaviour described in ivall/xcl#695 / #887; no xcl code was used (xcl is GPL-2.0).

Tested

  • Retail title 1.0.2.1 (package hashes verified) on a PC with no active playback device (every render endpoint Unknown). RTX 3080 Ti (driver 32.0.16.1060), i7-12700KF, 32 GB, Windows 11 Pro 26300, --profile diag --features diagnostics, this branch merged onto main ffe310e, scripted keys (VICTORY_KEYS) through the first-run menus.
    • Log: no active playback device: the title gets a silent audio endpoint at start; 30.0 fps throughout; no audio-thread assert. Captures show the intro key art (frame 1024) and the Rockstar legal terms screen with the Privacy Policy box ticked at frame 5400 (~3 min). Without this change, main and xcl main both hit that assert on this PC (~20–30 s).
    • The process ended by itself at ~4 min 15 s, with no error or exception in its output (stderr ends with the usual copy statistics). I have not found out why yet; it happened after the point this PR is about.
  • cargo clippy --workspace --all-targets --locked -- -D warnings and with --all-features: clean.
  • cargo test -p victory-hle --locked: 99 passed, 1 failed. The failure is modules::display::tests::sdr_and_display_deferrals (0x80070032), which fails the same way on clean main on this machine. The 6 new tests pass: routing native vs silent, the 48 kHz float format accepted / 44.1 kHz rejected, 20 buffer cycles → Stop (no signal) → Start → 20 more, dynamic object counting, and a real CoCreateInstance call (skips itself without an audio service).
  • cargo test -p xtask --locked: 4 passed.

Not tested

  • A PC with a playback device on the retail title (that path returns the host's enumerator unchanged; covered by the routing test only).
  • Linux/Wine with no sound driver (#222's case). The fix should apply there too, but I haven't run it.
  • AMD/Intel GPUs. The 10 ms / 480-frame period and the object counts are reasoned from the ISpatialAudio API, not observed from the title.

AI use: Claude Code (Claude Sonnet 5.5) implemented the change and tests; Claude Opus 5.5 reviewed it, ran the retail test on my machine and wrote this description. I reviewed it.

Fixes #834. Also covers the case #222 warns about.

🤖 Generated with Claude Code

**@⁠vladbondarenko97** on GitHub · 2026-11-24 14:17 UTC · [original](https://github.com/Marvisak/VIctory/pull/929) `vladbondarenko97:audio/silent-endpoint` → `main` · +813 −4 · 4 files · 3 commits · open With no active Windows playback device, the title's audio output setup never allocates its buffers and returns while still holding a lock. The audio thread then never drains the per-thread 96 KiB command streams, and about 20–30 s in the title's audio-thread assert fires (its own `int3`). This is the trap in #834, and the Wine/no-sound-driver case #222 warns about. The chain is diagnosed with RVAs in ivall/xcl#695. A console always has an output, so the title has no path for this. **What is in it** - `modules/audio/silent.rs` overrides the title's `CoCreateInstance` (`ole32.dll`, `api-ms-win-core-com-l1-*`; the retail exe imports it from `api-ms-win-core-com-l1-1-0.dll` and has no `CoCreateInstanceEx`/`CoGetClassObject` import). The host call always runs first. Only a successful `MMDeviceEnumerator`/`IMMDeviceEnumerator` creation without aggregation is looked at. - If the host has an ACTIVE render endpoint (or counting fails), the native enumerator is returned untouched, so PCs with audio see no change. Otherwise render flow shows one silent ACTIVE device; capture flow, other `GetDevice` ids and notifications go to the host. - The silent device's `ISpatialAudioClient` accepts 48 kHz float. Its `ISpatialAudioObjectRenderStream` signals the title's event every 10 ms while started, hands out 480-frame buffers and discards them. Start/Stop/Reset can be repeated, and dynamic objects are counted and capped. One info line is logged when it is used. - `windows`/`windows-core` become plain `cfg(windows)` dependencies (they were diagnostics-only). - Implemented independently, following the behaviour described in ivall/xcl#695 / #887; no xcl code was used (xcl is GPL-2.0). **Tested** - Retail title 1.0.2.1 (package hashes verified) on a PC with **no active playback device** (every render endpoint `Unknown`). RTX 3080 Ti (driver 32.0.16.1060), i7-12700KF, 32 GB, Windows 11 Pro 26300, `--profile diag --features diagnostics`, this branch merged onto `main` `ffe310e`, scripted keys (`VICTORY_KEYS`) through the first-run menus. - Log: `no active playback device: the title gets a silent audio endpoint` at start; 30.0 fps throughout; **no audio-thread assert**. Captures show the intro key art (frame 1024) and the **Rockstar legal terms screen with the Privacy Policy box ticked** at frame 5400 (~3 min). Without this change, `main` and xcl `main` both hit that assert on this PC (~20–30 s). - The process ended by itself at ~4 min 15 s, with no error or exception in its output (stderr ends with the usual copy statistics). I have not found out why yet; it happened after the point this PR is about. - `cargo clippy --workspace --all-targets --locked -- -D warnings` and with `--all-features`: clean. - `cargo test -p victory-hle --locked`: 99 passed, 1 failed. The failure is `modules::display::tests::sdr_and_display_deferrals` (0x80070032), which fails the same way on clean `main` on this machine. The 6 new tests pass: routing native vs silent, the 48 kHz float format accepted / 44.1 kHz rejected, 20 buffer cycles → Stop (no signal) → Start → 20 more, dynamic object counting, and a real `CoCreateInstance` call (skips itself without an audio service). - `cargo test -p xtask --locked`: 4 passed. **Not tested** - A PC *with* a playback device on the retail title (that path returns the host's enumerator unchanged; covered by the routing test only). - Linux/Wine with no sound driver (#222's case). The fix should apply there too, but I haven't run it. - AMD/Intel GPUs. The 10 ms / 480-frame period and the object counts are reasoned from the ISpatialAudio API, not observed from the title. **AI use:** Claude Code (Claude Sonnet 5.5) implemented the change and tests; Claude Opus 5.5 reviewed it, ran the retail test on my machine and wrote this description. I reviewed it. Fixes #834. Also covers the case #222 warns about. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The title plays its own mix through Windows audio: IMMDeviceEnumerator
from CoCreateInstance, then an ISpatialAudioClient on the default render
endpoint. With no active endpoint its output setup never allocates
buffers and returns holding a lock, the audio thread never drains the
title's command streams, and the title asserts at +0x4dcbc9d about
20-30 s in (#834, #222; ivall/xcl#695 has the diagnosis).

CoCreateInstance is now ours. Everything but the MMDeviceEnumerator goes
to the host unchanged, and so does an enumerator that reports an active
render endpoint. Otherwise the enumerator is wrapped: render flow lists
one silent, active device; capture flow stays the host's. The device's
spatial client takes 48 kHz float objects (a 7.1 bed, up to 111 dynamic
objects); its stream signals the title's event every 10 ms while
started and hands out buffers that are discarded. Start, Stop and Reset
can be repeated.

windows and windows-core are no longer diagnostics-only dependencies.

Written independently from the behaviour described in ivall/xcl#695 and
#887; no code was taken from xcl.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Hri58aiQKmMwqS6K8CHq2s
Cargo.toml of victory-hle: main made windows a plain dependency with the
D3D12 features; keep those, keep windows-core non-optional (the silent
endpoint's #[implement] needs it outside diagnostics builds).

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:14:23 +00:00
Author
Owner

@⁠MichaelSmithAI on GitHub · 2026-11-24 14:26 UTC · original

Independent Wine 11.22 result for the no-driver case on d80294f. With audio disabled in an isolated prefix, Wine’s own CoCreateInstance and endpoint enumeration succeeded, returned zero active playback devices, and returned 0x80070490 for the default endpoint. Through the VIctory hook, the same configuration exposed one active silent device. A spatial stream delivered three 480-frame float buffers.

Restoring the audio driver in the same prefix restored four active playback devices and a working default. The hook then returned the native endpoint. All six authored tests passed as well. This verifies fallback selection, buffer delivery and return to native routing on Wine. We did not launch the title in this comparison. The title reaching the legal screen is the author’s Windows 11 result.

**@⁠MichaelSmithAI** on GitHub · 2026-11-24 14:26 UTC · [original](https://github.com/Marvisak/VIctory/pull/929#issuecomment-7134371695) Independent Wine 11.22 result for the no-driver case on d80294f. With audio disabled in an isolated prefix, Wine’s own CoCreateInstance and endpoint enumeration succeeded, returned zero active playback devices, and returned 0x80070490 for the default endpoint. Through the VIctory hook, the same configuration exposed one active silent device. A spatial stream delivered three 480-frame float buffers. Restoring the audio driver in the same prefix restored four active playback devices and a working default. The hook then returned the native endpoint. All six authored tests passed as well. This verifies fallback selection, buffer delivery and return to native routing on Wine. We did not launch the title in this comparison. The title reaching the legal screen is the author’s Windows 11 result.
Author
Owner

@⁠dcastell1 on GitHub · 2026-11-24 14:28 UTC · original

Verified on native Windows (no Wine): NVIDIA GeForce RTX 5090 (driver 621.24), Windows 11 10.0.26300, Rust 1.98.1, MSVC 14.44.35207, debug build. main@ffe310e baseline on this box: 342 passed, 0 failed, 6 ignored.

cargo test --workspace
348 passed; 0 failed; 6 ignored   (exit 0)

Six more than the baseline: the silent playback endpoint path ships its tests and every one runs green here.

Tree restored afterwards (full diff against a clean checkout); no game data, the tests are synthetic. AI-assisted (opencode): applied the patch to a built tree, ran cargo test --workspace, reverted it.

**@⁠dcastell1** on GitHub · 2026-11-24 14:28 UTC · [original](https://github.com/Marvisak/VIctory/pull/929#issuecomment-7134436503) Verified on native Windows (no Wine): NVIDIA GeForce RTX 5090 (driver 621.24), Windows 11 10.0.26300, Rust 1.98.1, MSVC 14.44.35207, debug build. `main@ffe310e` baseline on this box: **342 passed, 0 failed, 6 ignored**. ``` cargo test --workspace 348 passed; 0 failed; 6 ignored (exit 0) ``` Six more than the baseline: the silent playback endpoint path ships its tests and every one runs green here. Tree restored afterwards (full diff against a clean checkout); no game data, the tests are synthetic. AI-assisted (opencode): applied the patch to a built tree, ran `cargo test --workspace`, reverted it.
Author
Owner

@⁠vladbondarenko97 on GitHub · 2026-11-24 14:56 UTC · original

Thanks for the reviews and the Wine and RTX 5090 runs. @⁠mercuryVM: done in 2b8756d. The module doc and this description now say "the title's audio-thread assert" with no offset (a doc-only commit on top, no code change).

**@⁠vladbondarenko97** on GitHub · 2026-11-24 14:56 UTC · [original](https://github.com/Marvisak/VIctory/pull/929#issuecomment-7135204001) Thanks for the reviews and the Wine and RTX 5090 runs. @⁠mercuryVM: done in 2b8756d. The module doc and this description now say "the title's audio-thread assert" with no offset (a doc-only commit on top, no code change).
Author
Owner

@⁠Zipettte on GitHub · 2026-11-24 15:40 UTC · original

Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at 2b8756d: cargo test -p victory-hle passes, 101 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed).

Tested with AI assistance (Claude).

**@⁠Zipettte** on GitHub · 2026-11-24 15:40 UTC · [original](https://github.com/Marvisak/VIctory/pull/929#issuecomment-7136433946) Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at 2b8756d: `cargo test -p victory-hle` passes, 101 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed). _Tested with AI assistance (Claude)._
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 01:29 UTC · original

Automated triage for the maintainers.

Needs work: needs the maintainer's decision. This adds modules/audio/silent.rs (crates/victory-hle). It overrides the title's CoCreateInstance, and only when a successful MMDeviceEnumerator creation finds no active render endpoint, it wraps the enumerator to offer one silent device. That device's ISpatialAudioClient/render stream accepts 48 kHz float, signals the title's event every 10 ms from a timer thread and discards buffers. Hosts with an active endpoint get the native enumerator back unchanged. The routing reads sensibly, and the PR gives evidence: a run of the title past the audio-thread assert on a PC with no playback device, plus an independent Wine check.

Points for the maintainer:

  • crates/victory-hle/Cargo.toml makes windows-core a non-optional dependency (it was diagnostics-only) and adds a windows feature, so release builds now link it.
  • The description says the behaviour follows a diagnosis in a GPL-2.0 project and that none of its code was used. The maintainer may want to confirm that's acceptable.
  • The 10 ms period, the 480-frame buffers and the object caps are reasoned from the host API, not observed from the title, as the description states.

CI: not run.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 01:29 UTC · [original](https://github.com/Marvisak/VIctory/pull/929#issuecomment-7149598606) <!-- victory-triage v1 head=1f23c491ce25dbb9e0c9d3d50555873c3d2f7700 verdict=needs-work at=2026-11-25T01:29:05Z --> Automated triage for the maintainers. **Needs work: needs the maintainer's decision.** This adds `modules/audio/silent.rs` (`crates/victory-hle`). It overrides the title's `CoCreateInstance`, and only when a successful `MMDeviceEnumerator` creation finds no active render endpoint, it wraps the enumerator to offer one silent device. That device's `ISpatialAudioClient`/render stream accepts 48 kHz float, signals the title's event every 10 ms from a timer thread and discards buffers. Hosts with an active endpoint get the native enumerator back unchanged. The routing reads sensibly, and the PR gives evidence: a run of the title past the audio-thread assert on a PC with no playback device, plus an independent Wine check. Points for the maintainer: - `crates/victory-hle/Cargo.toml` makes `windows-core` a non-optional dependency (it was diagnostics-only) and adds a `windows` feature, so release builds now link it. - The description says the behaviour follows a diagnosis in a GPL-2.0 project and that none of its code was used. The maintainer may want to confirm that's acceptable. - The 10 ms period, the 480-frame buffers and the object caps are reasoned from the host API, not observed from the title, as the description states. CI: not run. --- _Generated by [Claude Code](https://claude.ai/code)_
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/929/head:github-bot/gh-929'
git switch 'github-bot/gh-929'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-929'
git switch 'github-bot/gh-929'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-929'
git switch 'github-bot/gh-929'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-929'
git switch 'main'
git merge --squash 'github-bot/gh-929'
git switch 'main'
git merge --ff-only 'github-bot/gh-929'
git switch 'main'
git merge 'github-bot/gh-929'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!929
No description provided.