[PR #2133] silent_audio: an empty GetBuffer packet leaves nothing pending (SILENT-AUDIO-EMPTY-PACKET) #2137

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

📋 Pull Request Information

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

Base: main ← Head: fix/silent-audio-zero-frame-getbuffer


📝 Commits (1)

  • 6993f7a silent_audio: an empty GetBuffer packet leaves nothing pending (SILENT-AUDIO-EMPTY-PACKET)

📊 Changes

2 files changed (+11 additions, -0 deletions)

View changed files

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

📄 Description

Claimed in the coordination issue as: SILENT-AUDIO-EMPTY-PACKET (claim comment to follow)

What and why

runtime/shims/silent_audio.cpp AudioClient::get_buffer set pending_ for every successful IAudioRenderClient::GetBuffer, including GetBuffer(0). The GetBuffer remarks say the client must call ReleaseBuffer after a packet of any size other than 0, and may or may not release a packet of size 0.

A render loop that asks for its free space whatever it is and releases only what it filled does exactly that. The first event after priming the buffer before Start (the usual pattern, and what Start signals right away) finds the buffer full, so it gets an empty packet and moves on. From then on every GetBuffer returned AUDCLNT_E_OUT_OF_ORDER and Reset returned AUDCLNT_E_BUFFER_OPERATION_PENDING: the stream never took audio again. A ReleaseBuffer(5) after the empty packet returned AUDCLNT_E_INVALID_SIZE instead of AUDCLNT_E_OUT_OF_ORDER.

An empty packet now returns S_OK without marking anything pending. Measured with a small probe against Windows 11's audio engine (default render endpoint, shared mode, 100 ms buffer):

call sequence Windows 11 shim before shim after
GetBuffer(0) S_OK, null pointer same same
then Reset(), no release S_OK AUDCLNT_E_BUFFER_OPERATION_PENDING succeeds
then GetBuffer(10), no release S_OK AUDCLNT_E_OUT_OF_ORDER S_OK
GetBuffer(0), then ReleaseBuffer(5) AUDCLNT_E_OUT_OF_ORDER AUDCLNT_E_INVALID_SIZE AUDCLNT_E_OUT_OF_ORDER
GetBuffer(0) while 10 frames are held AUDCLNT_E_OUT_OF_ORDER same same

The measured title activates ISpatialAudioClient first (docs/runtime_imports.md), so this is the IAudioClient path's contract, for any caller that takes it.

Tested

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

  • silent_audio_test gets four checks before the stream is primed: GetBuffer(0) gets an empty packet, ReleaseBuffer(5) after it is out of order, Reset succeeds, and a second empty packet left unreleased does not block the priming that follows. On main those and 10 later checks fail (the empty packet stays pending and the priming, the run and Reset all fail); with the fix all 133 checks pass.
  • The full CPU ctest (162 tests) passes.
  • scripts/check_no_game_data.py on both files.

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/2133 **Author:** [@syfyra](https://github.com/syfyra) **Created:** 11/25/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/silent-audio-zero-frame-getbuffer` --- ### 📝 Commits (1) - [`6993f7a`](https://github.com/ubiquitarianism/leonida/commit/6993f7a6b1bd1f4a3bf8d34125e8fb2f8c5d1d57) silent_audio: an empty GetBuffer packet leaves nothing pending (SILENT-AUDIO-EMPTY-PACKET) ### 📊 Changes **2 files changed** (+11 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `runtime/shims/silent_audio.cpp` (+5 -0) 📝 `runtime/test/silent_audio_test.cpp` (+6 -0) </details> ### 📄 Description Claimed in the coordination issue as: SILENT-AUDIO-EMPTY-PACKET (claim comment to follow) ### What and why `runtime/shims/silent_audio.cpp` `AudioClient::get_buffer` set `pending_` for every successful `IAudioRenderClient::GetBuffer`, including `GetBuffer(0)`. The GetBuffer remarks say the client must call ReleaseBuffer after a packet of any size other than 0, and may or may not release a packet of size 0. A render loop that asks for its free space whatever it is and releases only what it filled does exactly that. The first event after priming the buffer before `Start` (the usual pattern, and what `Start` signals right away) finds the buffer full, so it gets an empty packet and moves on. From then on every `GetBuffer` returned `AUDCLNT_E_OUT_OF_ORDER` and `Reset` returned `AUDCLNT_E_BUFFER_OPERATION_PENDING`: the stream never took audio again. A `ReleaseBuffer(5)` after the empty packet returned `AUDCLNT_E_INVALID_SIZE` instead of `AUDCLNT_E_OUT_OF_ORDER`. An empty packet now returns `S_OK` without marking anything pending. Measured with a small probe against Windows 11's audio engine (default render endpoint, shared mode, 100 ms buffer): | call sequence | Windows 11 | shim before | shim after | |---|---|---|---| | `GetBuffer(0)` | `S_OK`, null pointer | same | same | | then `Reset()`, no release | `S_OK` | `AUDCLNT_E_BUFFER_OPERATION_PENDING` | succeeds | | then `GetBuffer(10)`, no release | `S_OK` | `AUDCLNT_E_OUT_OF_ORDER` | `S_OK` | | `GetBuffer(0)`, then `ReleaseBuffer(5)` | `AUDCLNT_E_OUT_OF_ORDER` | `AUDCLNT_E_INVALID_SIZE` | `AUDCLNT_E_OUT_OF_ORDER` | | `GetBuffer(0)` while 10 frames are held | `AUDCLNT_E_OUT_OF_ORDER` | same | same | The measured title activates `ISpatialAudioClient` first (docs/runtime_imports.md), so this is the `IAudioClient` path's contract, for any caller that takes it. ### Tested Windows 11, MSVC 14.44 (Build Tools), RelWithDebInfo: - `silent_audio_test` gets four checks before the stream is primed: `GetBuffer(0)` gets an empty packet, `ReleaseBuffer(5)` after it is out of order, `Reset` succeeds, and a second empty packet left unreleased does not block the priming that follows. On `main` those and 10 later checks fail (the empty packet stays pending and the priming, the run and `Reset` all fail); with the fix all 133 checks pass. - The full CPU ctest (162 tests) passes. - `scripts/check_no_game_data.py` on both files. 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#2137
No description provided.