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

Closed
syfyra wants to merge 1 commit from upstream-pr/2133 into main
syfyra commented 2026-11-25 22:27:13 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by syfyra on 2026-11-25T22:27:13Z.


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

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5500252091 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2133). Originally posted by [syfyra](https://github.com/syfyra) on 2026-11-25T22:27:13Z. --- 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)
fiestorra commented 2026-11-30 10:32:14 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by fiestorra on 2026-11-30T10:32:14Z.


Independent verification on this machine (Windows 11, MSVC 19.44.35226), with a negative control that bites on two assertions.

1. It applies. merge-tree clean; the commits cherry-pick onto main 012b79a67 without a conflict. Two files: runtime/shims/silent_audio.cpp and runtime/test/silent_audio_test.cpp.

2. With the branch its test passes:

ctest -R 'silent_audio'
100% tests passed, 0 tests failed out of 1

3. The control - revert only the shim, keep the test:

git checkout origin/main -- runtime/shims/silent_audio.cpp
cmake --build … --target silent_audio_test
ctest -R 'silent_audio' --output-on-failure
0% tests passed, 1 tests failed out of 1
FAIL an empty packet has nothing to release
FAIL an empty packet leaves Reset no buffer operation pending

Both failures name the change: an empty audio packet must be a no-op for the buffer-release path, and must not leave Reset with a pending buffer operation. main's shim does one or both, and the test says which.

What I did not test: the rest of silent_audio.cpp's surface (it is a shim for a title's audio device), and whether the empty-packet rule matches what the console's API actually promises - I established that the test fails without the change, which is the reviewer's open question here.

Why I am commenting: I verify open pull requests that replay onto current main, build the binaries their tests name in ctest --show-only=json-v1, run them, and then revert only the source change to see which tests stop passing. 17 controls so far; 12 bite.

Written with an AI assistant.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7275734465 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2133#issuecomment-7275734465). Originally posted by [fiestorra](https://github.com/fiestorra) on 2026-11-30T10:32:14Z. --- Independent verification on this machine (Windows 11, MSVC 19.44.35226), with a negative control that bites on two assertions. **1. It applies.** `merge-tree` clean; the commits cherry-pick onto `main` `012b79a67` without a conflict. Two files: `runtime/shims/silent_audio.cpp` and `runtime/test/silent_audio_test.cpp`. **2. With the branch its test passes:** ``` ctest -R 'silent_audio' 100% tests passed, 0 tests failed out of 1 ``` **3. The control - revert only the shim, keep the test:** ``` git checkout origin/main -- runtime/shims/silent_audio.cpp cmake --build … --target silent_audio_test ctest -R 'silent_audio' --output-on-failure 0% tests passed, 1 tests failed out of 1 FAIL an empty packet has nothing to release FAIL an empty packet leaves Reset no buffer operation pending ``` **Both failures name the change**: an empty audio packet must be a no-op for the buffer-release path, and must not leave `Reset` with a pending buffer operation. `main`'s shim does one or both, and the test says which. **What I did not test:** the rest of `silent_audio.cpp`'s surface (it is a shim for a title's audio device), and whether the empty-packet rule matches what the console's API actually promises - **I established that the test fails without the change**, which is the reviewer's open question here. **Why I am commenting:** I verify open pull requests that replay onto current `main`, build the binaries their tests name in `ctest --show-only=json-v1`, run them, and then revert **only** the source change to see which tests stop passing. **17 controls so far; 12 bite.** Written with an AI assistant.
aslan2142 commented 2026-12-01 12:22:24 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T12:22:24Z.


Marking Ready for Review since no WIP/blocker reason for draft status is specified on this PR, so it can enter normal CI and review.

(AI-assisted triage.)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7311037934 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2133#issuecomment-7311037934). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T12:22:24Z. --- Marking Ready for Review since no WIP/blocker reason for draft status is specified on this PR, so it can enter normal CI and review. *(AI-assisted triage.)*
aslan2142 commented 2026-12-01 16:42:27 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T16:42:27Z.


Closing this PR because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (d3d12/) available now. Thank you for the contribution! If you believe this PR was closed by mistake (for example, if it still applies to active tools, d3d12/, or general docs), please feel free to reopen it.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7318075229 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2133#issuecomment-7318075229). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T16:42:27Z. --- Closing this PR because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (`d3d12/`) available now. Thank you for the contribution! If you believe this PR was closed by mistake (for example, if it still applies to active tools, `d3d12/`, or general docs), please feel free to reopen it.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
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.

Reference
ProjectLeonida/mandy!2133
No description provided.