[PR #2387] silent_audio: the silent endpoint answers four argument checks as Windows does (SILENT-AUDIO-HOST-ANSWERS) #2390

Open
opened 2026-11-26 21:21:05 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/2387
Author: @syfyra
Created: 11/26/2026
Status: 🔄 Open

Base: main ← Head: fix/silent-audio-host-answers


📝 Commits (1)

  • d38ef53 silent_audio: the silent endpoint answers four argument checks as Windows does (SILENT-AUDIO-HOST-ANSWERS)

📊 Changes

2 files changed (+72 additions, -5 deletions)

View changed files

📝 runtime/shims/silent_audio.cpp (+25 -5)
📝 runtime/test/silent_audio_test.cpp (+47 -0)

📄 Description

Claimed in the coordination issue as: SILENT-AUDIO-HOST-ANSWERS

What and why

I ran the same IAudioClient / IAudioRenderClient calls against the host's default render endpoint and against the silent endpoint (LEONIDA_AUDIO=silent), side by side in one probe built with silent_audio.cpp, on Windows 11, with a fresh client for each case. Most answers already match. Four calls answer differently:

call host shim on main
Initialize / IsFormatSupported with a malformed WAVEFORMATEX: nChannels, nSamplesPerSec or wBitsPerSample 0, nBlockAlign or nAvgBytesPerSec not following from them, WAVE_FORMAT_EXTENSIBLE with cbSize < 22 E_INVALIDARG AUDCLNT_E_UNSUPPORTED_FORMAT; a wrong nAvgBytesPerSec was taken as a valid format
Initialize with a malformed format on a client that is already initialized AUDCLNT_E_ALREADY_INITIALIZED AUDCLNT_E_UNSUPPORTED_FORMAT (the format was checked first)
GetService(IAudioCaptureClient) on the render client AUDCLNT_E_WRONG_ENDPOINT_TYPE E_NOINTERFACE
Reset when there is nothing to reset (never started, or reset already) S_OK S_FALSE
IAudioRenderClient::ReleaseBuffer(n, flags), n > 0, with any flag but AUDCLNT_BUFFERFLAGS_SILENT and bit 31 (one bit at a time over all 32) E_INVALIDARG, checked before the size, and the packet stays pending flags ignored, released

Each is now answered as the host does. The order of the checks follows the host too:

  • a null format or a null closest is still E_POINTER first;
  • a ReleaseBuffer with nothing pending is still AUDCLNT_E_OUT_OF_ORDER before the flags are read;
  • a 0-frame ReleaseBuffer does not look at the flags (the host returns S_OK there).

Not changed, because the answers depend on the device and engine rather than on the call: which well-formed formats are supported (the shim takes any PCM or float format on purpose), the Initialize stream-flag checks (the host's answers per bit are irregular), and the host's own Initialize refusal of 12-bit or 64-channel formats.

Tested

Windows 11, MSVC 14.44 (Build Tools), RelWithDebInfo:

  • silent_audio_test gets five checks, matching the table:

    • six malformed formats on a fresh client each: IsFormatSupported and Initialize are both E_INVALIDARG, and nothing comes back in closest;
    • an initialized client with a malformed format answers AUDCLNT_E_ALREADY_INITIALIZED;
    • GetService(IAudioCaptureClient) is AUDCLNT_E_WRONG_ENDPOINT_TYPE;
    • two Resets of an unused stream are S_OK;
    • ReleaseBuffer with DATA_DISCONTINUITY, 0x10, and 0x4 with an oversized count is E_INVALIDARG, and the packet is still released afterwards.

    On main, 5 checks fail, plus one follow-on: main released the packet on the bad flag, so the later release of it fails. With this branch, 134 of 134 pass.

  • Merged together with #2133 and #2134, which also change this file and test: 139 of 139 pass. Both merge cleanly with it (scripts/pr_overlap.py from #2349).

  • scripts/check_no_game_data.py on both files.

Not tested under Wine.

GPUs tested: n/a (CPU tests)

AI-assisted: yes (Claude Code, Claude Opus 5.5)

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a: no translator change)

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/2387 **Author:** [@syfyra](https://github.com/syfyra) **Created:** 11/26/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/silent-audio-host-answers` --- ### 📝 Commits (1) - [`d38ef53`](https://github.com/ubiquitarianism/leonida/commit/d38ef5384cec157eb17804961283239ffd51481d) silent_audio: the silent endpoint answers four argument checks as Windows does (SILENT-AUDIO-HOST-ANSWERS) ### 📊 Changes **2 files changed** (+72 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `runtime/shims/silent_audio.cpp` (+25 -5) 📝 `runtime/test/silent_audio_test.cpp` (+47 -0) </details> ### 📄 Description Claimed in the coordination issue as: SILENT-AUDIO-HOST-ANSWERS ### What and why I ran the same `IAudioClient` / `IAudioRenderClient` calls against the host's default render endpoint and against the silent endpoint (`LEONIDA_AUDIO=silent`), side by side in one probe built with `silent_audio.cpp`, on Windows 11, with a fresh client for each case. Most answers already match. Four calls answer differently: | call | host | shim on `main` | |---|---|---| | `Initialize` / `IsFormatSupported` with a malformed `WAVEFORMATEX`: `nChannels`, `nSamplesPerSec` or `wBitsPerSample` 0, `nBlockAlign` or `nAvgBytesPerSec` not following from them, `WAVE_FORMAT_EXTENSIBLE` with `cbSize` < 22 | `E_INVALIDARG` | `AUDCLNT_E_UNSUPPORTED_FORMAT`; a wrong `nAvgBytesPerSec` was taken as a valid format | | `Initialize` with a malformed format on a client that is already initialized | `AUDCLNT_E_ALREADY_INITIALIZED` | `AUDCLNT_E_UNSUPPORTED_FORMAT` (the format was checked first) | | `GetService(IAudioCaptureClient)` on the render client | `AUDCLNT_E_WRONG_ENDPOINT_TYPE` | `E_NOINTERFACE` | | `Reset` when there is nothing to reset (never started, or reset already) | `S_OK` | `S_FALSE` | | `IAudioRenderClient::ReleaseBuffer(n, flags)`, `n` > 0, with any flag but `AUDCLNT_BUFFERFLAGS_SILENT` and bit 31 (one bit at a time over all 32) | `E_INVALIDARG`, checked before the size, and the packet stays pending | flags ignored, released | Each is now answered as the host does. The order of the checks follows the host too: - a null format or a null `closest` is still `E_POINTER` first; - a `ReleaseBuffer` with nothing pending is still `AUDCLNT_E_OUT_OF_ORDER` before the flags are read; - a 0-frame `ReleaseBuffer` does not look at the flags (the host returns `S_OK` there). Not changed, because the answers depend on the device and engine rather than on the call: which well-formed formats are supported (the shim takes any PCM or float format on purpose), the `Initialize` stream-flag checks (the host's answers per bit are irregular), and the host's own `Initialize` refusal of 12-bit or 64-channel formats. ### Tested Windows 11, MSVC 14.44 (Build Tools), RelWithDebInfo: - `silent_audio_test` gets five checks, matching the table: - six malformed formats on a fresh client each: `IsFormatSupported` and `Initialize` are both `E_INVALIDARG`, and nothing comes back in `closest`; - an initialized client with a malformed format answers `AUDCLNT_E_ALREADY_INITIALIZED`; - `GetService(IAudioCaptureClient)` is `AUDCLNT_E_WRONG_ENDPOINT_TYPE`; - two `Reset`s of an unused stream are `S_OK`; - `ReleaseBuffer` with `DATA_DISCONTINUITY`, `0x10`, and `0x4` with an oversized count is `E_INVALIDARG`, and the packet is still released afterwards. On `main`, 5 checks fail, plus one follow-on: main released the packet on the bad flag, so the later release of it fails. With this branch, 134 of 134 pass. - Merged together with #2133 and #2134, which also change this file and test: 139 of 139 pass. Both merge cleanly with it (`scripts/pr_overlap.py` from #2349). - `scripts/check_no_game_data.py` on both files. Not tested under Wine. GPUs tested: n/a (CPU tests) AI-assisted: yes (Claude Code, Claude Opus 5.5) ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (n/a: no translator change) 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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
starred/leonida#2390
No description provided.