fix(libSceAudioOut): count completed AudioOut2 grains in the queue level #6474
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6474"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by fdfawef324 on 2026-10-15T16:38:20Z.
What
Black Myth: Wukong (PPSA23226) stops 20 s after its first frame, while it loads at 0.1 FPS:
Its AudioOut2 output is Wwise's sink, linked into the eboot. I read it in the relinked executable:
queue_depth4 (the sink's default).IsDataNeededcallssceAudioOut2ContextGetQueueLevel(ctx, NULL, &available)and returnsavailableas the number of frames the sound engine renders.sceAudioOut2ContextAdvanceand signals a semaphore (guest0x111e1e30, the frame in the crash stack, run on one of the game's worker threads).AK::AudioOutThreadwaits on that semaphore, callssceAudioOut2ContextPush(ctx, 1)and wakes the sound engine.Every advance is pushed. They pile up because of the level the title is given. With an SDL device the level is the pushed grains beyond the 40 ms cushion. At startup and after the device runs dry, the pushes that refill the cushion leave the level at 0, so each wake after such a push asks for a full queue again. With
queue_depth4 that adds 3 completed grains per push, and an advance throws after the fifth push.sceAudioOut2ContextGetQueueLevelnow also counts the grains that Advance completed and no push has consumed, up toqueue_depth. A title that renders what the level leaves room for then keeps at mostqueue_depthgrains ahead of its pushes.Pushstill waits only on the pushed grains, so a completed grain goes out as soon as the device has room. The level changes only while completed grains await a push, so titles that never call Advance are unaffected.The console behaviour is not known. No SDK header or console measurement says whether the console's level counts advanced grains that have not been pushed, or how many such grains a context can hold. The new technical-debt entry records this. The 16-grain limit stays.
#6216 removes the 16-grain limit for PPSA26358, which stops with the same message. That avoids the stop but leaves the backlog growing. With only that change, this PR's test still fails: its producer gets more than
queue_depthgrains ahead. The two PRs change different lines.The regression test drives a context the way the sink does:
queue_depth4, render as many distinct grains asavailablereports, push one per poll. It checks that the producer never gets more thanqueue_depthgrains ahead and that all 48 grains play in order.Tested
Windows Server 2025, WinLibs GCC 15.2, Release, SDL disk audio driver:
audio_out2_port_buffersonmainaborts with the PPSA23226 message after its fifth push. Withmain's limit removed (as in #6216) it aborts on the queue-depth check. With this change it passes 5 of 5 runs (1.8 s).audio_out*tests pass.tools/check_conventions.py --base upstream/mainandgit diff --checkpass.PPSA23226, Windows Server 2025, RTX 3060 (driver 591.86), cold shader cache:
main71bd2876e: stops 172 s in, 20 s after its first frame, with the message above.0029e62f9(172 commits after71bd2876e, with nolibSceAudioOutchange between them): no AudioOut2 error. The run went on until the harness's timed dump at 1,786 s, with 8,544 frames presented and 5.92 FPS in the window title at the end. The harness stops dumping after 20 frames, so the dumps cover only the first few minutes. They show the Initial Setup, brightness and "Personal Information Protection Policy" screens.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-15T18:09:27Z.
Review: COMMENTED
Linux run, since the PR only has Windows runs.
Ubuntu 26.04, i7-8700, gcc 15.2, Release,
BUILD_TESTING=ON, full build. Head2321f1ac7applied onmain03c4cb5e7. Headless, so SDL picks the disk audio driver.AudioOut2PortBuffers.cpponmain's source):audio_out2_port_buffersaborts withAudioOut2: more than 16 completed grains await a push.audio_out2_port_bufferspasses 10 of 10 runs (1.5 s each), and the 17audio_out*tests pass 5 times in a row (-j1 --repeat until-fail:5).-E "^agc|gpu|vulkan|video_out",-j8): same result asmain. Onlyfile_writer_binaryandfile_writer_textfail, onmaintoo (this host's coreutils rejects the command they run).Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
Imported from boykopovar/AnyPS5. Originally posted by fdfawef324 on 2026-10-15T20:01:44Z.
I ran this on Black Myth: Wukong (PPSA23226). Setup: Windows Server 2025, RTX 3060 12 GB (driver 591.86), Ryzen 9 5900X, MinGW GCC 15.2 Release, cold shader cache in both runs.
main71bd2876e: stops 172 s in, 20 s after its first frame, with 5 frames presented:2321f1ac7, on its base0029e62f9, which is 172 commits after71bd2876ewith nolibSceAudioOutchange between them): no AudioOut2 error. It ran until the harness's timed dump at 1,786 s. By then it had presented 8,544 frames, and the window title showed 5.92 FPS. The harness stops dumping after 20 frames, so the dumps cover only the first few minutes. They show the Initial Setup, brightness and "Personal Information Protection Policy" screens.I've added this to the Tested section.
AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-16T18:40:10Z.
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.
docs/dev/debt/libSceAudioOut.mddocs/dev/debt/libSceAudioOut.mddocs/dev/debt/libSceAudioOut.mddocs/dev/debt/libSceAudioOut.mdImported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-17T13:05:28Z.
A data point from Resident Evil Village (PPSA01556), which stops with this PR's message too. Windows 11 (10.0.26300), RTX 3070 Laptop (driver 617.42), Ryzen 9 5900HS. The trees are local test trees based on
main, withmain'slibSceAudioOut.Without this PR, one run stopped 11.1 minutes into the boot, after the startup dialogs and before the title screen:
It's intermittent here. Two other runs of the same tree that evening didn't stop this way, and no other Resident Evil Village run we've logged since 2026-10-12 did.
With this PR (
2321f1ac7fcherry-picked onto that tree, and onto variants of it that change only the AGC driver), 10 runs went through the boot and the title:AudioOut2line.Because the stop was rare without the PR, these runs show the change running through boot, title and menu without a new AudioOut2 problem, rather than proving the fix on this game. No scene was loaded, so gameplay isn't covered.