fix(libSceAudioOut): validate the debug state id and size in sceAudioOut2SetSystemDebugState #9838

Merged
JAB-dev merged 3 commits from upstream-pr/9838 into main 2026-10-23 02:36:09 +00:00
JAB-dev commented 2026-10-22 17:00:02 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by JAB-dev on 2026-10-22T17:00:02Z.


What

sceAudioOut2SetSystemDebugState now accepts only the debug state the console accepts instead of every id with any size. The loudness state (id 1, an 8-byte param) still returns 0. Any other id, and id 1 with another size, returns 0x80268001 (invalid param), and a null pointer returns 0x8026800C (invalid pointer; the repo returned 0x80260502, which is not an AudioOut2 error code). The console also accepts id 0x20 with a 4-byte param, which the SDK does not document; that case throws, as does a loudness param whose data pointer is null (the console reads the loudness mode from it unchecked).

Source: the PS5 SDK defines SCE_AUDIO_OUT2_DEBUG_STATE_ID_LOUDNESS as 1, SceAudioOut2SystemDebugStateLoudnessParam as the loudness param (a mode and flags, 8 bytes) and SceAudioOut2SystemDebugStateParam as the debug state struct (debugStateId at +0, param pointer at +8, paramSize at +0x10), and declares sceAudioOut2SetSystemDebugState(const SceAudioOut2SystemDebugStateParam *debugStateParam) (audio_out2.h). In PS5 firmware 3.20 and 4.03, sceAudioOut2SetSystemDebugState checks the null pointer, then the id, then the size, and forwards the loudness mode. 4.03 has the same checks plus the id 0x20 with size 4 case. Both return 0x80268001 for any other id or size.

The not-initialized error (0x80268006) that the console checks first is not modelled because sceAudioOut2Initialize keeps no state on main.

Tested

Windows 11 x64, MinGW GCC 15.2.0 (WinLibs r7), Release, -DBUILD_TESTING=ON, on main 8499ea52e5.

  • audio_out2_latency (existing test, TestSetSystemDebugState rewritten): {id 1, 8 bytes} returns 0 twice; id 1 with sizes 0, 4 and 16 and ids 0, 2, 0x21 and 0xFFFFFFFF with size 8 return 0x80268001; id 0x20 with sizes 8 and 0 returns 0x80268001; id 0x20 with size 4 and id 1 with a null param throw; a null pointer returns 0x8026800C. The expected codes are literal SDK values.
  • With AudioOut2System.cpp from main and the new test kept, audio_out2_latency aborts (exit code 0xc0000409): id 1 with size 0 is accepted (returns 0) where 0x80268001 is expected. With the change it passes. The old test passed an id 1 param with size 0 and expected 0, which the console refuses.
  • python tools/check_conventions.py --base origin/main passes and git diff --check is clean.

Linux not tested.

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 (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4971093354 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9838). Originally posted by [JAB-dev](https://github.com/JAB-dev) on 2026-10-22T17:00:02Z. --- ### What `sceAudioOut2SetSystemDebugState` now accepts only the debug state the console accepts instead of every id with any size. The loudness state (id 1, an 8-byte param) still returns 0. Any other id, and id 1 with another size, returns `0x80268001` (invalid param), and a null pointer returns `0x8026800C` (invalid pointer; the repo returned `0x80260502`, which is not an AudioOut2 error code). The console also accepts id `0x20` with a 4-byte param, which the SDK does not document; that case throws, as does a loudness param whose data pointer is null (the console reads the loudness mode from it unchecked). Source: the PS5 SDK defines `SCE_AUDIO_OUT2_DEBUG_STATE_ID_LOUDNESS` as 1, `SceAudioOut2SystemDebugStateLoudnessParam` as the loudness param (a mode and flags, 8 bytes) and `SceAudioOut2SystemDebugStateParam` as the debug state struct (`debugStateId` at +0, `param` pointer at +8, `paramSize` at +0x10), and declares `sceAudioOut2SetSystemDebugState(const SceAudioOut2SystemDebugStateParam *debugStateParam)` (`audio_out2.h`). In PS5 firmware 3.20 and 4.03, `sceAudioOut2SetSystemDebugState` checks the null pointer, then the id, then the size, and forwards the loudness mode. 4.03 has the same checks plus the id `0x20` with size 4 case. Both return `0x80268001` for any other id or size. The not-initialized error (`0x80268006`) that the console checks first is not modelled because `sceAudioOut2Initialize` keeps no state on `main`. ### Tested Windows 11 x64, MinGW GCC 15.2.0 (WinLibs r7), Release, `-DBUILD_TESTING=ON`, on `main` 8499ea52e5. - `audio_out2_latency` (existing test, `TestSetSystemDebugState` rewritten): `{id 1, 8 bytes}` returns 0 twice; id 1 with sizes 0, 4 and 16 and ids 0, 2, 0x21 and 0xFFFFFFFF with size 8 return `0x80268001`; id `0x20` with sizes 8 and 0 returns `0x80268001`; id `0x20` with size 4 and id 1 with a null param throw; a null pointer returns `0x8026800C`. The expected codes are literal SDK values. - With `AudioOut2System.cpp` from `main` and the new test kept, `audio_out2_latency` aborts (exit code 0xc0000409): id 1 with size 0 is accepted (returns 0) where `0x80268001` is expected. With the change it passes. The old test passed an id 1 param with size 0 and expected 0, which the console refuses. - `python tools/check_conventions.py --base origin/main` passes and `git diff --check` is clean. Linux not tested. ### 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](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
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!9838
No description provided.