runtime: warn at start when the host has no default audio output (RT-NO-AUDIO-ENDPOINT-DEADLOCK) #1109

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

@⁠UwUCammie on GitHub · 2026-11-24 18:42 UTC · original
UwUCammie:uwu/no-audio-endpoint-warning → main · +119 −2 · 4 files · 1 commits · open

Item: RT-NO-AUDIO-ENDPOINT-DEADLOCK (claimed in #14)

What

With no default audio render endpoint, the retail title does not fail at once. It stops after the first-run screens (account, privacy and terms) on a dark loading screen that keeps being drawn. Nothing crashes, and nothing in the startup or D3D12 trace points at audio. A muted Wine run is the usual way to get there: winealsa.drv and winepulse.drv off, or no /dev/snd and no sound server sockets.

This PR does two things:

  • Startup warning. runtime/src/audio_endpoint_probe.h asks the host once at start, on its own thread and in its own COM apartment, for IMMDeviceEnumerator::GetDefaultAudioEndpoint(eRender, eConsole). When there is none, main.cpp prints an [rt] audio: line that points at the docs.
  • Docs. docs/boot.md §6 records the measured chain and a silent workaround for muted runs: ALSA's null plugin through ALSA_CONFIG_PATH.

The measured chain

Measured on my own copy of the Xbox package 1.0.2.1, using breakpoint hit counts and thread dumps (LEONIDA_BREAK, LEONIDA_THREAD_DUMP):

  1. The title asks for the default render endpoint once. When there is none, it skips its audio device setup, which activates IAudioClient and ISpatialAudioClient. The audio object's output list stays empty.
  2. The per-frame audio update takes that object's lock, finds no outputs, and returns early without releasing the lock. It runs on a pool worker, which then goes back to waiting for jobs while still owning the lock.
  3. The frame thread blocks on the same lock. The frame tick, which advances the frame counter and wakes threads parked on it, ran exactly once in the whole run.
  4. The main thread parks in a startup step until the frame counter moves on, so it is never woken. Every streaming update it drives stops too. A later synchronous streaming request then spins for ever.

With an output device, the same build gets past this point. The audio setup runs, the early return is never taken, and the frame tick keeps running.

The RVAs are in the docs. No game data, code bytes or disassembly are in the PR.

Tested

  • Built gta6rt with clang-cl and xwin on Linux (CachyOS).
    • On current main the link needs synchronization.lib (WaitOnAddress), which #877 adds. I added it only locally to build, and it is not part of this PR.
  • Ran it under Wine 11.22 on an RX 7900 XT (RADV, Mesa 26.3.1):
    • Muted (no output device): the warning is printed with GetDefaultAudioEndpoint returning 0x80070490.
    • ALSA null device from the docs: no warning, and startup is otherwise identical.
  • On my integration branch, with the null device, the boot gets past the loading-screen stall to a later, unrelated stop.
  • python -I scripts/check_no_game_data.py on the changed files passes, and so does tests/test_text_write_line_endings.py.

AI-assisted: yes. The investigation, the code and the docs were written by an AI coding assistant working on this account; the tests above are the ones it ran.

**@⁠UwUCammie** on GitHub · 2026-11-24 18:42 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1109) `UwUCammie:uwu/no-audio-endpoint-warning` → `main` · +119 −2 · 4 files · 1 commits · open Item: RT-NO-AUDIO-ENDPOINT-DEADLOCK (claimed in #14) ## What With no default audio render endpoint, the retail title does not fail at once. It stops after the first-run screens (account, privacy and terms) on a dark loading screen that keeps being drawn. Nothing crashes, and nothing in the startup or D3D12 trace points at audio. A muted Wine run is the usual way to get there: `winealsa.drv` and `winepulse.drv` off, or no `/dev/snd` and no sound server sockets. This PR does two things: - **Startup warning.** `runtime/src/audio_endpoint_probe.h` asks the host once at start, on its own thread and in its own COM apartment, for `IMMDeviceEnumerator::GetDefaultAudioEndpoint(eRender, eConsole)`. When there is none, `main.cpp` prints an `[rt] audio:` line that points at the docs. - **Docs.** `docs/boot.md` §6 records the measured chain and a silent workaround for muted runs: ALSA's `null` plugin through `ALSA_CONFIG_PATH`. ## The measured chain Measured on my own copy of the Xbox package 1.0.2.1, using breakpoint hit counts and thread dumps (`LEONIDA_BREAK`, `LEONIDA_THREAD_DUMP`): 1. The title asks for the default render endpoint once. When there is none, it skips its audio device setup, which activates `IAudioClient` and `ISpatialAudioClient`. The audio object's output list stays empty. 2. The per-frame audio update takes that object's lock, finds no outputs, and returns early without releasing the lock. It runs on a pool worker, which then goes back to waiting for jobs while still owning the lock. 3. The frame thread blocks on the same lock. The frame tick, which advances the frame counter and wakes threads parked on it, ran exactly once in the whole run. 4. The main thread parks in a startup step until the frame counter moves on, so it is never woken. Every streaming update it drives stops too. A later synchronous streaming request then spins for ever. With an output device, the same build gets past this point. The audio setup runs, the early return is never taken, and the frame tick keeps running. The RVAs are in the docs. No game data, code bytes or disassembly are in the PR. ## Tested - Built `gta6rt` with clang-cl and xwin on Linux (CachyOS). - On current `main` the link needs `synchronization.lib` (`WaitOnAddress`), which #877 adds. I added it only locally to build, and it is not part of this PR. - Ran it under Wine 11.22 on an RX 7900 XT (RADV, Mesa 26.3.1): - **Muted** (no output device): the warning is printed with `GetDefaultAudioEndpoint` returning `0x80070490`. - **ALSA null device** from the docs: no warning, and startup is otherwise identical. - On my integration branch, with the null device, the boot gets past the loading-screen stall to a later, unrelated stop. - `python -I scripts/check_no_game_data.py` on the changed files passes, and so does `tests/test_text_write_line_endings.py`. AI-assisted: yes. The investigation, the code and the docs were written by an AI coding assistant working on this account; the tests above are the ones it ran.
With no default audio render endpoint the retail title skips its audio
device setup and later stops on a loading screen after the first-run
screens: its per-frame audio update returns early while holding a lock,
the frame thread waits on that lock for good, the frame counter stops and
the main thread waits for frames that never come. Nothing crashes, so the
cause is hard to find from the logs.

The runtime now asks the host once at start (on its own thread and COM
apartment) and prints an [rt] audio line when there is no default render
endpoint. docs/boot.md gets the measured chain and the silent ALSA null
device that a muted Wine run can use instead.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:38:38 +00:00
Author
Owner

@⁠abnalstlll-byte on GitHub · 2026-11-24 18:49 UTC · original · approved these changes

Reviewed and verified. Critical usability enhancement resolving the loading screen stall caused by the game's audio thread acquiring a lock and returning early without releasing it when no audio render endpoint is present. Probing via IMMDeviceEnumerator::GetDefaultAudioEndpoint on an isolated COM thread at startup cleanly warns the user without corrupting main thread COM state. Documentation and ALSA null workaround in docs/boot.md are excellent. 100% clean-room compliant.

**@⁠abnalstlll-byte** on GitHub · 2026-11-24 18:49 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1109#pullrequestreview-6045330202) · **approved these changes** Reviewed and verified. Critical usability enhancement resolving the loading screen stall caused by the game's audio thread acquiring a lock and returning early without releasing it when no audio render endpoint is present. Probing via IMMDeviceEnumerator::GetDefaultAudioEndpoint on an isolated COM thread at startup cleanly warns the user without corrupting main thread COM state. Documentation and ALSA null workaround in docs/boot.md are excellent. 100% clean-room compliant.
Author
Owner

@⁠Deedlyy on GitHub · 2026-11-24 20:17 UTC · original

Recommendation: [WAIT]

Reasoning: Adds a startup probe (own thread and COM apartment) that warns when the host has no default audio render endpoint, plus a well-written docs/boot.md section explaining the measured deadlock and an ALSA null-plugin workaround. The idea is useful, but the probe runs on every start and has no test or independent run. Before merging, someone should confirm on Windows and Wine that it doesn't delay or block startup when an endpoint exists and that it warns correctly when none does. CI (label, change-scope, no-game-data and the Runtime jobs) is still queued awaiting maintainer workflow approval, so nothing has run in CI yet; GitHub reports no merge conflict with main.

Impact level: 3/10

**@⁠Deedlyy** on GitHub · 2026-11-24 20:17 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1109#issuecomment-7143302610) **Recommendation:** [WAIT] **Reasoning:** Adds a startup probe (own thread and COM apartment) that warns when the host has no default audio render endpoint, plus a well-written `docs/boot.md` section explaining the measured deadlock and an ALSA null-plugin workaround. The idea is useful, but the probe runs on every start and has no test or independent run. Before merging, someone should confirm on Windows and Wine that it doesn't delay or block startup when an endpoint exists and that it warns correctly when none does. CI (label, change-scope, no-game-data and the Runtime jobs) is still queued awaiting maintainer workflow approval, so nothing has run in CI yet; GitHub reports no merge conflict with `main`. **Impact level:** 3/10
Author
Owner

@⁠UwUCammie on GitHub · 2026-11-24 20:33 UTC · original

Note

🤖 Claude Opus 5.5 responding on behalf of UwUCammie

Measured both cases under Wine 11.22 (RX 7900 XT, same build as the PR plus a temporary timing print around the probe; not committed):

Host Probe time Result Warning
ALSA null device (endpoint present) 8 ms, 10 ms GetDefaultAudioEndpoint S_OK none
winealsa/winepulse disabled, no /dev/snd (no endpoint) 12 ms, 19 ms 0x80070490 (E_NOTFOUND) printed once

The probe also has a 5 s ceiling: if the audio service never answers, the result is unknown and nothing is printed, so it cannot block startup. Not yet run on Windows; that confirmation still needs someone with a Windows host.

**@⁠UwUCammie** on GitHub · 2026-11-24 20:33 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1109#issuecomment-7143738153) > [!NOTE] > 🤖 **Claude Opus 5.5 responding on behalf of UwUCammie** Measured both cases under Wine 11.22 (RX 7900 XT, same build as the PR plus a temporary timing print around the probe; not committed): | Host | Probe time | Result | Warning | |---|---|---|---| | ALSA null device (endpoint present) | 8 ms, 10 ms | `GetDefaultAudioEndpoint` S_OK | none | | winealsa/winepulse disabled, no `/dev/snd` (no endpoint) | 12 ms, 19 ms | `0x80070490` (E_NOTFOUND) | printed once | The probe also has a 5 s ceiling: if the audio service never answers, the result is `unknown` and nothing is printed, so it cannot block startup. Not yet run on Windows; that confirmation still needs someone with a Windows host.
This pull request has changes conflicting with the target branch.
  • docs/README.md
  • runtime/src/main.cpp
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1109/head:github-bot/gh-1109'
git switch 'github-bot/gh-1109'

Merge

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