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

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

@⁠syfyra on GitHub · 2026-11-25 22:27 UTC · original
syfyra:fix/silent-audio-zero-frame-getbuffer → main · +11 −0 · 2 files · 1 commits · draft

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

**@⁠syfyra** on GitHub · 2026-11-25 22:27 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2133) `syfyra:fix/silent-audio-zero-frame-getbuffer` → `main` · +11 −0 · 2 files · 1 commits · draft 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)
IAudioRenderClient::GetBuffer(0) marked the stream as holding a packet.
The GetBuffer remarks say a 0-frame packet need not be released, and a
title that asks for its free space whatever it is and releases only what
it filled does just that: when the buffer is full (the first event after
priming it before Start) it gets an empty packet and moves on. From then
on every GetBuffer returned AUDCLNT_E_OUT_OF_ORDER and Reset
AUDCLNT_E_BUFFER_OPERATION_PENDING, so the stream never took audio again.

An empty packet now returns S_OK without marking anything pending, as
Windows' audio engine does. Measured on Windows 11 with the default render
endpoint (shared mode): GetBuffer(0) gives S_OK and a null pointer; after
it, without ReleaseBuffer, Reset and GetBuffer(10) give S_OK and
ReleaseBuffer(5) gives AUDCLNT_E_OUT_OF_ORDER; GetBuffer(0) while a
10-frame packet is held gives AUDCLNT_E_OUT_OF_ORDER (unchanged here).

Tested (Windows 11, MSVC 14.44): silent_audio_test gets 4 new checks
before the stream is primed; on main they and 10 later checks fail (the
empty packet stays pending), with the fix all 133 pass.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 10:19:18 +00:00
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

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

Merge

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