Skip to content

RT-SILENT-AUDIO-ENDPOINT: serve a silent output endpoint when the host has none (the boot's audio-lock stop) - #1598

Merged
aslan2142 merged 2 commits into
ProjectLeonida:mainfrom
aslan2142:silent-audio-endpoint
Nov 25, 2026
Merged

aslan2142 merged 2 commits into
ProjectLeonida:mainfrom
aslan2142:silent-audio-endpoint

Conversation

@aslan2142

Copy link
Copy Markdown
Collaborator

Item: RT-SILENT-AUDIO-ENDPOINT. The claim could not be posted: coordination issue #14 is at GitHub's 2,500-comment limit and has no successor yet. The claim text, to be copied there once there is one:

claiming: RT-SILENT-AUDIO-ENDPOINT - when the host has no audio output, CoCreateInstance(MMDeviceEnumerator) answers render questions with an in-process silent output endpoint (and LEONIDA_AUDIO=silent forces it), so the title's audio start takes its console path

Searched first: no claim or open pull request covers this.

What and why

On a host with no audio output, the title's GetDefaultAudioEndpoint(eRender) returns 0x80070490. Its audio device start then takes an error path that leaves its output-device lock held, and the audio engine never mixes. A main-thread command buffer fills up, and the boot stops on an int3 about 47 s in. Refusing the enumerator altogether gives the same stop. A console always has an output.

Measured on the retail boot first, without code:

  • a diagnostic thread dump showed the engine thread waiting on a lock held by an idle job worker;
  • a private sound server with only a null sink, so still no sound, removed the stop.

CoCreateInstance(MMDeviceEnumerator) now goes to shims/silent_audio.cpp (hooked in shims/com_shim.cpp).

  • A host enumerator that has a render endpoint is returned unchanged.
  • Otherwise, or with the new LEONIDA_AUDIO=silent, render questions get an in-process endpoint that never opens a host device and throws every sample away. It serves:
    • ISpatialAudioClient/2, which is what the title activates: a 7.1 static bed, mono 48 kHz float objects, and an event every 10 ms;
    • IAudioClient/2/3 with render client, clock and volume services.
  • Capture keeps the host's answer.
  • One [rt] line names the reason.
  • Docs: the variable is in runtime/README.md, and the behaviour in docs/runtime_imports.md ("Audio output off the console (WASAPI)").
  • Not measured on a console: 7.1 as the mix format and a bed with 0 dynamic objects. Both are written down as hypotheses.

Tests

  • New silent_audio_test: 129 checks, using stand-in hosts, so no host audio is touched. It covers the enumerator with no endpoint, with one and with none at all; forced mode; event-driven, polled and spatial streams running on their clock; and the hook with LEONIDA_AUDIO=silent.
  • Red check: against main's com_shim.cpp, the hook checks fail.
  • Windows suite under Wine 11.22 (clang-cl build), llvmpipe and an RDNA2 iGPU (RADV): no test goes from pass to fail; silent_audio is new and passes on both.
  • Python checks: test_docs_env_vars, test_docs_links, test_docs_repo_paths, test_ci_registration and test_ctest_registration pass.

Measured on the retail boot

Wine, no audio driver at all, RDNA2 iGPU; counts only. Measured with #1539 merged locally, since RADV loses the device without it. It is not needed to build or merge this.

build run time end D3D12 calls presents
main 48 s the title's int3 about 112k 144
this branch 300 s (time limit) 0 exceptions 135k 367
this branch, LEONIDA_AUDIO=silent 300 s (time limit) 0 exceptions 135k 365

AI-assisted (Claude Code, Claude Opus 5.5).

aslan2142 and others added 2 commits November 25, 2026 00:05
The title creates its MMDeviceEnumerator through CoCreateInstance. On a host with no
render endpoint, GetDefaultAudioEndpoint(eRender) is 0x80070490, the title's audio device
start leaves its own output-device lock held, the audio engine never mixes, and the boot
stops on an int3 about 47 s in. A console always has an output.

com_shim's CoCreateInstance now hands that class to shims/silent_audio.cpp. A host
enumerator with a default render endpoint is returned unchanged. Otherwise (no endpoint,
no enumerator, or LEONIDA_AUDIO=silent) render questions get an in-process endpoint:
IMMDevice with a read-only property store, IAudioClient/2/3 at 48 kHz float 7.1, and
IAudioRenderClient, IAudioClock, ISimpleAudioVolume and IAudioStreamVolume. A clock drains
the padding in real time and an event-driven stream's event is signalled every 10 ms.
Every sample is discarded; no host audio device is opened. Capture keeps the host's
answer. One [rt] line names the reason when the silent device is first served.

silent_audio_test covers stand-in hosts with and without an endpoint, no host, a render
stream over a few periods, and the CoCreateInstance hook with LEONIDA_AUDIO=silent.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The title activates ISpatialAudioClient on the render device, not IAudioClient (the first
game run with the silent endpoint logged that IID and stopped as before). The silent device
now answers ISpatialAudioClient and ISpatialAudioClient2: a 7.1 static bed, no dynamic
objects, mono 48 kHz float objects, 480 frames a pass. Its ISpatialAudioObjectRenderStream
signals the stream's event every 10 ms while it runs, and its objects write into a
scratch buffer. The periodic event thread is shared with IAudioClient.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@aslan2142
aslan2142 merged commit 42537e7 into ProjectLeonida:main Nov 25, 2026
2 of 5 checks passed
@aslan2142

Copy link
Copy Markdown
Collaborator Author

Merged as a boot-blocker fix: on a host with no audio output, the retail boot now runs past the audio-lock stop at about 47 s (counts in the description).

  • Claim: RT-SILENT-AUDIO-ENDPOINT, in the description, because Coordinating who works on what #14 is full.
  • Who it changes nothing for: hosts with an audio output keep their own enumerator unchanged. Capture always keeps the host's answer.
  • No sound, by construction: the silent endpoint never opens a host device. LEONIDA_AUDIO=silent forces it, for muted test runs.
  • Tests: Windows suite under Wine (llvmpipe and an RDNA2 iGPU), with nothing going from pass to fail; silent_audio_test is new; and a red check against main's com_shim.cpp.
  • Review welcome after the fact, in particular the 7.1 bed and the 0 dynamic objects, which are hypotheses (written down as such in docs/runtime_imports.md).
  • Checked on main c7e82e26e + 018145b33: it merges cleanly; the semantic suite passes (487 files, 6,279 tests, 0 files failed); the 14 docs and writer tests pass; check_no_game_data.py is clean on the 8 changed files.

AI-assisted (Claude Code, Claude Opus 5.5).

aslan2142 added a commit that referenced this pull request Nov 25, 2026
scripts/build_runtime.ps1 conflicted in the $files list of the build
without CMake: main added shims\silent_audio.cpp there (#1598) after this
branch had merged main, and this branch adds shims\lifecycle.cpp. Both
entries are kept, lifecycle.cpp where this branch had it. The branch's
other change in that file (user32.lib on the link line) merged cleanly.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@aslan2142
aslan2142 deleted the silent-audio-endpoint branch November 25, 2026 09:22
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.

1 participant