fix(audio): retain completed AudioOut2 grains until pushed #6216

Merged
eljackjoestar-cmd merged 1 commit from upstream-pr/6216 into main 2026-10-17 13:06:50 +00:00
eljackjoestar-cmd commented 2026-10-15 04:21:03 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by eljackjoestar-cmd on 2026-10-15T04:21:03Z.


What

During a level-loading test, Lost Soul Aside (PPSA26358) queued more than sixteen completed audio grains before Push consumed them. sceAudioOut2ContextAdvance then threw AudioOut2: more than 16 completed grains await a push, terminating the process.

Remove the emulator's sixteen-grain restriction. Completed PCM and gain snapshots remain queued in order until sceAudioOut2ContextPush consumes them. The regression advances 64 distinct grains on a producer thread using a rewritten buffer, ends that thread, then pushes and checks every stereo output sample. The technical-debt note records that an unconsumed backlog retains PCM storage and that a console backlog limit is unverified.

Tested

  • Windows 11, WinLibs GCC 15.2, Release. audio_out2_port_buffers fails with the new regression and main's implementation, throwing at the seventeenth advance; it passes with this change (1.78 s). Rebased onto current main 0afa6a607ed0; all 10 focused audio checks pass again (7.27 s).
  • All 10 audio_out2_* and audio_out_shutdown checks pass (3.80 s), covering PCM order, rewritten buffers, gain snapshots, cross-thread pushes, output timing and shutdown.
  • Title A/B: the same local integration on main a077a88df, with existing #5851, #5870 and #5872 (lazy preparation enabled), a missing-metadata PlayGo diagnostic and -onethread, using the same relinked executable. Before this change the run aborted in AudioOut2 during loading; with this change it passes that point. The user confirmed gameplay in run173; a later run with the same verified executable/module hashes (run177) also reached gameplay, captured through the game window with the combat tutorial visible. The cutscene ran around 6 FPS and the later scene around 1 FPS, with substantial memory pressure; sustained playability is not established. Run173 was stopped by the old stdout logging guard, not a demonstrated allocation failure. This does not resolve the separate garbage-collection timeout seen with the normal threaded launch. #5851 has since been closed in favor of #6060; the recorded integration above retained the tested #5851 version. Runtime diagnostics and other integration changes are absent from this PR.
  • tools/check_conventions.py --base origin/main and git diff --check pass.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw; no silent stub added
  • No investigation files or images added to the repository
  • New third-party code is a submodule built from source: n/a
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Unblocks: PPSA26358 #4401 (the AudioOut2 backlog abort; gameplay entry observed in the disclosed integration, performance remains poor)
  • GPUs tested: n/a (audio change)
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4868136404 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6216). Originally posted by [eljackjoestar-cmd](https://github.com/eljackjoestar-cmd) on 2026-10-15T04:21:03Z. --- ### What During a level-loading test, Lost Soul Aside (PPSA26358) queued more than sixteen completed audio grains before Push consumed them. `sceAudioOut2ContextAdvance` then threw `AudioOut2: more than 16 completed grains await a push`, terminating the process. Remove the emulator's sixteen-grain restriction. Completed PCM and gain snapshots remain queued in order until `sceAudioOut2ContextPush` consumes them. The regression advances 64 distinct grains on a producer thread using a rewritten buffer, ends that thread, then pushes and checks every stereo output sample. The technical-debt note records that an unconsumed backlog retains PCM storage and that a console backlog limit is unverified. ### Tested - Windows 11, WinLibs GCC 15.2, Release. `audio_out2_port_buffers` fails with the new regression and main's implementation, throwing at the seventeenth advance; it passes with this change (1.78 s). Rebased onto current main `0afa6a607ed0`; all 10 focused audio checks pass again (7.27 s). - All 10 `audio_out2_*` and `audio_out_shutdown` checks pass (3.80 s), covering PCM order, rewritten buffers, gain snapshots, cross-thread pushes, output timing and shutdown. - Title A/B: the same local integration on main `a077a88df`, with existing #5851, #5870 and #5872 (lazy preparation enabled), a missing-metadata PlayGo diagnostic and `-onethread`, using the same relinked executable. Before this change the run aborted in AudioOut2 during loading; with this change it passes that point. The user confirmed gameplay in run173; a later run with the same verified executable/module hashes (run177) also reached gameplay, captured through the game window with the combat tutorial visible. The cutscene ran around 6 FPS and the later scene around 1 FPS, with substantial memory pressure; sustained playability is not established. Run173 was stopped by the old stdout logging guard, not a demonstrated allocation failure. This does not resolve the separate garbage-collection timeout seen with the normal threaded launch. #5851 has since been closed in favor of #6060; the recorded integration above retained the tested #5851 version. Runtime diagnostics and other integration changes are absent from this PR. - `tools/check_conventions.py --base origin/main` and `git diff --check` pass. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except technical debt - [x] Unimplemented paths throw; no silent stub added - [x] No investigation files or images added to the repository - [x] New third-party code is a submodule built from source: n/a - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Unblocks: PPSA26358 #4401 (the AudioOut2 backlog abort; gameplay entry observed in the disclosed integration, performance remains poor) - [x] GPUs tested: n/a (audio change) - [x] AI-assisted: yes
Dextroid17 commented 2026-10-15 15:04:41 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-15T15:04:41Z.


I ran the test case this PR adds, on Linux.

Setup: head 6575aa217 merged into main at ff23657f3 (no conflicts; the PR's base is 262 commits behind), Linux, default CMake build (CMAKE_BUILD_TYPE empty, unoptimized), clean environment (env -i with only HOME, PATH and VK_ICD_FILENAMES set). ctest -R '^audio_out2_port_buffers$', 3 runs each.

  • with this PR: 3 of 3 runs pass.
  • with core/libs/prx/libSceAudioOut/src/AudioOut2Context.cpp put back to main's version (the PR's test changes kept): 3 of 3 runs fail, each aborting on main's 16-grain limit (uncaught std::runtime_error: "AudioOut2: more than 16 completed grains await a push").

The test uses SDL's disk audio driver, so no sound device was involved. I did not run Lost Soul Aside.
I did not check Windows or macOS.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6195271609 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6216#issuecomment-6195271609). Originally posted by [Dextroid17](https://github.com/Dextroid17) on 2026-10-15T15:04:41Z. --- I ran the test case this PR adds, on Linux. Setup: head 6575aa217 merged into main at ff23657f3 (no conflicts; the PR's base is 262 commits behind), Linux, default CMake build (CMAKE_BUILD_TYPE empty, unoptimized), clean environment (`env -i` with only HOME, PATH and VK_ICD_FILENAMES set). `ctest -R '^audio_out2_port_buffers$'`, 3 runs each. - with this PR: 3 of 3 runs pass. - with core/libs/prx/libSceAudioOut/src/AudioOut2Context.cpp put back to main's version (the PR's test changes kept): 3 of 3 runs fail, each aborting on main's 16-grain limit (uncaught `std::runtime_error`: "AudioOut2: more than 16 completed grains await a push"). The test uses SDL's disk audio driver, so no sound device was involved. I did not run Lost Soul Aside. I did not check Windows or macOS. AI-assisted: yes
isnisk commented 2026-10-15 16:26:50 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by isnisk on 2026-10-15T16:26:50Z.


Checked on Linux: Ubuntu 26.04 (WSL2), GCC 15.2.0, Release, this head (6575aa217) merged onto main 489466d3f (clean merge).

  • With the change: audio_out2_port_buffers and the other 16 audio_out* tests pass, 3 rounds, including the four audio_out*_shutdown tests from #6000; no compiler warnings.
  • Without it (main's AudioOut2Context.cpp, the new test kept): audio_out2_port_buffers aborts 3 of 3 with what(): AudioOut2: more than 16 completed grains await a push.
  • check_conventions.py --base origin/main passes.

Not checked: macOS, the title.

AI-assisted: yes (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6196985029 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6216#issuecomment-6196985029). Originally posted by [isnisk](https://github.com/isnisk) on 2026-10-15T16:26:50Z. --- Checked on Linux: Ubuntu 26.04 (WSL2), GCC 15.2.0, Release, this head (`6575aa217`) merged onto `main` `489466d3f` (clean merge). - With the change: `audio_out2_port_buffers` and the other 16 `audio_out*` tests pass, 3 rounds, including the four `audio_out*_shutdown` tests from #6000; no compiler warnings. - Without it (`main`'s `AudioOut2Context.cpp`, the new test kept): `audio_out2_port_buffers` aborts 3 of 3 with `what(): AudioOut2: more than 16 completed grains await a push`. - `check_conventions.py --base origin/main` passes. Not checked: macOS, the title. AI-assisted: yes (Claude Code).
github-actions[bot] commented 2026-10-16 18:37:33 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-16T18:37:33Z.


Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 5021 docs/dev/debt/libSceAudioOut.md
PR 6447 docs/dev/debt/libSceAudioOut.md
PR 6493 docs/dev/debt/libSceAudioOut.md
PR 6964 docs/dev/debt/libSceAudioOut.md
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6222261575 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6216#issuecomment-6222261575). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-16T18:37:33Z. --- <!-- pr-overlap --> Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap. | Pull request | Shared files not compared | |---|---| | [PR 5021](https://www.github.com/boykopovar/AnyPS5/pull/5021) | `docs/dev/debt/libSceAudioOut.md` | | [PR 6447](https://www.github.com/boykopovar/AnyPS5/pull/6447) | `docs/dev/debt/libSceAudioOut.md` | | [PR 6493](https://www.github.com/boykopovar/AnyPS5/pull/6493) | `docs/dev/debt/libSceAudioOut.md` | | [PR 6964](https://www.github.com/boykopovar/AnyPS5/pull/6964) | `docs/dev/debt/libSceAudioOut.md` |
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
boykopovar/AnyPS5!6216
No description provided.