fix(libSceNgs2): return INVALID_VOICE_ACCESS for PLAY on a voice that was never set up #9926
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/9926"
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 JAB-dev on 2026-10-22T22:00:47Z.
What
sceNgs2VoiceControlandsceNgs2VoiceRunCommandsnow fail aPLAYevent on a voice that has no channels (never set up). They return0x804A8351(SCE_NGS2_ERROR_INVALID_VOICE_ACCESS), the voice stays idle with state flags 0, and the rest of a parameter list after the failing event is not applied. Before, the voice went to the playing state and never left it: with no channels the renderer never reaches the code that ends a voice with no data left, so its state flags stayedINUSE | PLAYINGforever.A title that frees its sound slots by polling
sceNgs2VoiceGetStateFlagsfor 0 then leaks one slot per such sound. Void Terrarium (PPSA03061, US) does this: it sends a stop-immediately event, an add of no waveform blocks and a play event to a voice it never set up. With a fresh save its pool of 32 sound-effect slots fills after the first level, and the next sound dereferences a null effect:The title does not crash on a console, which matches the library behaviour below.
Source
Measured by loading the decrypted PS5 firmware 3.20 and 4.03
libSceNgs2.native.sprxin a test harness and calling it directly (inputs and outputs only; nothing from the firmware is in the repository). The two firmware builds give identical results. The title's own calls only work with this module: it sends the PS5 event values (PLAY is 1), the 144-byte system option and the 0x108-byte delay parameter, and the plainlibSceNgs2.sprxin the same firmware is the PS4 library (PS4 event values and option sizes). With a sampler voice patched to a mastering voice at 48000 Hz and grain 256:0x804A8351, the others 00x804A83510x804A8351sceNgs2VoiceRunCommands0x804A83510x804A83510x804A8351each0x804A8351; the first volume is applied, the second is not0x804A8351; the setup is not appliedSCE_NGS2_ERROR_INVALID_VOICE_ACCESSis0x804A8351in the PS5 SDKngs2_errors.h. The PS4 11.00 library returns0x804A0052for the same sequence, so a PS4 value is not the PS5 one. The guard covers every rack, as the module does. An all-zero setup on a voice that already has a setup is ignored, as in the module, so the guard does not fail a play after it. Two behaviours of the module are not reproduced and are listed in the library's technical debt file: the flags of a set-up voice given no blocks, and an add of no blocks to a voice that already played and ended.I found no open or merged PR that implements this guard. The open PRs that touch
SetEventor the NGS2 error constants do something else: a different reverb change and error codes for other calls.Tested
Windows 11 x64, GCC 15.2 (WinLibs), Release, on
main8eb8e39207.ngs2_voiceeventstest sends the play through both entry points to a sampler voice with no setup and checks the return code, state flags 0 and silent output over three renders. It then checks that a play after setup succeeds with exactlyINUSE, in a command, in one parameter list after the setup, and that the same list with the play first still fails and leaves the voice idle. Unset submixer, reverb and mastering voices fail the same way. Onmainit aborts at line 26 (NGS2 check failed at line 26).ngs2tests pass (ctest -R ngs2).tools/check_conventions.py --base origin/mainandgit diff --checkpass.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 MarcZX10 on 2026-10-23T05:46:52Z.
Review: COMMENTED
The guard and regression coverage match the firmware observations in the description: both entry points return
SCE_NGS2_ERROR_INVALID_VOICE_ACCESS(0x804A8351) before setting PLAY, and the test covers state/output and setup recovery. The title currently saysINVALID_NUM_CHANNELS, which does not match the implemented/tested error name; please correct it or explain the distinction.\n\nCurrent-main sync reports 304 commits behind withcore/libs/prx/libSceNgs2.native/include/Ngs2Types.hppanddocs/dev/debt/libSceNgs2.native.mdchanged on both sides since merge base. Please refresh and preserve the intervening error/type and debt entries, then rerun the NGS2 suite. Current-main whitespace and conventions pass.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-23T05:46:53Z.
Review: DISMISSED
Please correct the PR title: it says
INVALID_NUM_CHANNELS, but the described firmware measurement, implementation, and tests all useSCE_NGS2_ERROR_INVALID_VOICE_ACCESS(0x804A8351). Also refresh onto current main and resolve/preserve changes in the sharedNgs2Types.hppandlibSceNgs2.native.mdfiles; current sync is 304 commits behind. After refreshing, rerun the focused NGS2 tests. The exact-head code and reported Windows/title evidence otherwise look sound; current-main conventions and diff-check pass.