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

Open
vladbondarenko97 wants to merge 3 commits from upstream-pr/929 into main
vladbondarenko97 commented 2026-11-24 14:17:38 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by vladbondarenko97 on 2026-11-24T14:17:38Z.


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

<!-- greyfinch-sync:Marvisak/VIctory:issue:6583831750 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/929). Originally posted by [vladbondarenko97](https://github.com/vladbondarenko97) on 2026-11-24T14:17:38Z. --- 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)
DenRakEiw commented 2026-11-24 15:03:23 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-24T14:21:20Z.

Review: APPROVED


Tested merged cleanly onto main (ffe310e) on Windows 11 x64 (Rust 1.98.1 MSVC):

  • cargo test -p victory-hle: 100 passed, 0 failed (plus no_dll_planting: 1 passed), including modules::audio::silent::tests::the_stream_signals_every_period_and_restarts
  • cargo clippy -p victory-hle --all-targets: 0 warnings
  • cargo xtask policy: ok (156 files ok)

Clean silent-endpoint fallback for hosts without an audio render device. Approving.

AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6040909287 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/929#pullrequestreview-6040909287). Originally posted by [DenRakEiw](https://github.com/DenRakEiw) on 2026-11-24T14:21:20Z. **Review:** APPROVED --- Tested merged cleanly onto `main` (`ffe310e`) on Windows 11 x64 (Rust 1.98.1 MSVC): - `cargo test -p victory-hle`: **100 passed, 0 failed** (plus `no_dll_planting`: 1 passed), including `modules::audio::silent::tests::the_stream_signals_every_period_and_restarts` - `cargo clippy -p victory-hle --all-targets`: **0 warnings** - `cargo xtask policy`: ok (`156 files ok`) Clean silent-endpoint fallback for hosts without an audio render device. Approving. AI-assisted (Gemini 4 Neon).
mercuryVM commented 2026-11-24 15:03:23 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by mercuryVM on 2026-11-24T14:23:50Z.

Review: APPROVED


Tested d80294f on Windows 11, RTX 5070, MSVC: cargo test -p victory-hle 101 passed, including the silent-endpoint tests. cargo clippy -p victory-hle --all-targets is clean, and cargo check -p victory --features diagnostics is clean. This host has an active render device, so the silent path is covered by the unit tests only, and the title wasn't run.

  • The routing is conservative: only CLSID_MMDeviceEnumerator is wrapped, and only when the host enumerator reports no active render endpoint. Everything else, and an enumerator that has a device, goes to the host's CoCreateInstance unchanged. No other HLE module overrides CoCreateInstance, so there's no ordering clash.
  • Making windows/windows-core non-optional for victory-hle costs some build time in non-diagnostics builds, but it's needed for #[implement].
  • Asset policy nit: the module doc and the PR text cite a title image offset for the assert (title+0x…). It doesn't help a reader of the code, and the repo avoids title-specific data, so I'd describe it as "the title's audio-thread assert" without the offset.

AI-assisted (Claude Code).

<!-- greyfinch-sync:Marvisak/VIctory:review:6040959722 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/929#pullrequestreview-6040959722). Originally posted by [mercuryVM](https://github.com/mercuryVM) on 2026-11-24T14:23:50Z. **Review:** APPROVED --- Tested d80294f on Windows 11, RTX 5070, MSVC: `cargo test -p victory-hle` 101 passed, including the silent-endpoint tests. `cargo clippy -p victory-hle --all-targets` is clean, and `cargo check -p victory --features diagnostics` is clean. This host has an active render device, so the silent path is covered by the unit tests only, and the title wasn't run. - The routing is conservative: only `CLSID_MMDeviceEnumerator` is wrapped, and only when the host enumerator reports no active render endpoint. Everything else, and an enumerator that has a device, goes to the host's `CoCreateInstance` unchanged. No other HLE module overrides `CoCreateInstance`, so there's no ordering clash. - Making `windows`/`windows-core` non-optional for `victory-hle` costs some build time in non-diagnostics builds, but it's needed for `#[implement]`. - Asset policy nit: the module doc and the PR text cite a title image offset for the assert (`title+0x…`). It doesn't help a reader of the code, and the repo avoids title-specific data, so I'd describe it as "the title's audio-thread assert" without the offset. AI-assisted (Claude Code).
MichaelSmithAI commented 2026-11-24 15:04:02 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by MichaelSmithAI on 2026-11-24T14:26:13Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7134371695 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/929#issuecomment-7134371695). Originally posted by [MichaelSmithAI](https://github.com/MichaelSmithAI) on 2026-11-24T14:26:13Z. --- 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.
dcastell1 commented 2026-11-24 15:04:03 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by dcastell1 on 2026-11-24T14:28:35Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7134436503 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/929#issuecomment-7134436503). Originally posted by [dcastell1](https://github.com/dcastell1) on 2026-11-24T14:28:35Z. --- 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.
vladbondarenko97 commented 2026-11-24 15:04:17 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by vladbondarenko97 on 2026-11-24T14:56:42Z.


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).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7135204001 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/929#issuecomment-7135204001). Originally posted by [vladbondarenko97](https://github.com/vladbondarenko97) on 2026-11-24T14:56:42Z. --- 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).
Zipettte commented 2026-11-24 16:05:18 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Zipettte on 2026-11-24T15:40:54Z.


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).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7136433946 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/929#issuecomment-7136433946). Originally posted by [Zipettte](https://github.com/Zipettte) on 2026-11-24T15:40:54Z. --- 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)._
Marvisak commented 2026-11-25 02:06:06 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T01:29:06Z.


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

<!-- greyfinch-sync:Marvisak/VIctory:comment:7149598606 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/929#issuecomment-7149598606). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T01:29:06Z. --- <!-- 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 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/929:upstream-pr/929'
git switch 'upstream-pr/929'

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/929'
git switch 'upstream-pr/929'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/929'
git switch 'upstream-pr/929'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/929'
git switch 'main'
git merge --squash 'upstream-pr/929'
git switch 'main'
git merge --ff-only 'upstream-pr/929'
git switch 'main'
git merge 'upstream-pr/929'
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
Marvisak/VIctory!929
No description provided.