fix(libSceAudioOut): refuse system debug state and chat calls before sceAudioOut2Initialize #12425

Merged
SeaSunPT merged 1 commit from upstream-pr/12425 into main 2026-10-29 09:40:39 +00:00
SeaSunPT commented 2026-10-28 13:11:17 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by SeaSunPT on 2026-10-28T13:11:17Z.


What

Before sceAudioOut2Initialize, sceAudioOut2SetSystemDebugState, sceAudioOut2EnableChat and sceAudioOut2DisableChat went straight to their own work: sceAudioOut2EnableChat() set the chat flag and returned 0, and sceAudioOut2SetSystemDebugState checked its pointer, id and size. The console returns 0x80268006 (not initialized) from all three. Each now returns 0x80268006 first when AudioOut2IsInitialized_nid_no_patch() is false, as the mastering calls do since #11244, and changes no state.

Source:

  • sceAudioOut2SetSystemDebugState: #9838 (https://github.com/boykopovar/AnyPS5/pull/9838) read the export in PS5 firmware 3.20 and 4.03 and states that the console checks 0x80268006 first, before the null pointer, id and size checks. It left the check out only because sceAudioOut2Initialize kept no state on main then.
  • sceAudioOut2EnableChat and sceAudioOut2DisableChat: the debt entry (f7a7be1a2) records that both PS5 exports take no arguments and return 0x80268006 before AudioOut2 initialization, then call the system chat service with selector 3. Neither has another check before the service call, so the order question does not arise.

The two debt entries lose the closed clause; the rest stays open: the debug state is still only traced, id 0x20 with a 4-byte param still throws, and the chat calls still have no chat service behind them.

Tested

Windows 11 Pro 26200, WinLibs GCC 15.2.0 r7, Ninja, Release, -DBUILD_TESTING=ON, on main 750cf6cf48.

  • audio_out2_latency (existing test, new TestSystemBeforeInitialize run in main before sceAudioOut2Initialize): sceAudioOut2SetSystemDebugState with the loudness state, a null pointer, id 2, id 1 with size 4, id 0x20 with size 4 and id 1 with a null param all return 0x80268006 (the last two throw after initialization, so the check comes first), and sceAudioOut2EnableChat and sceAudioOut2DisableChat return 0x80268006. The existing TestSetSystemDebugState and TestEnableChat that run after initialization pass unchanged.
  • With AudioOut2System.cpp from main and the new test kept, audio_out2_latency fails on its first new check (a debug state before AudioOut2 initialization is refused). With only the sceAudioOut2EnableChat guard removed it fails on enabling chat before AudioOut2 initialization is refused, and with only the sceAudioOut2DisableChat guard removed on disabling chat before AudioOut2 initialization is refused. With the change it passes.
  • ctest --test-dir build -R "audio" --output-on-failure, three runs: 56/56 passed each time.
  • ctest --test-dir build -R "public_headers" --output-on-failure: 65/65 passed.
  • ctest --test-dir build -j 8 --output-on-failure: 2811/2811 passed, 11 of them skipped (Vulkan feature, SDL pad and fopen tests that skip on this machine, none in libSceAudioOut).
  • No build warnings in the changed files.
  • python tools/check_conventions.py --base origin/main passes; git diff --check is clean.
  • python tools/pr_overlap.py --branch fix/audioout2-chat-debug-state-not-initialized: no overlap; #5021 conflicts with main and only shares docs/dev/debt/libSceAudioOut.md, so it could not be compared.

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:5051035199 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12425). Originally posted by [SeaSunPT](https://github.com/SeaSunPT) on 2026-10-28T13:11:17Z. --- ### What Before `sceAudioOut2Initialize`, `sceAudioOut2SetSystemDebugState`, `sceAudioOut2EnableChat` and `sceAudioOut2DisableChat` went straight to their own work: `sceAudioOut2EnableChat()` set the chat flag and returned 0, and `sceAudioOut2SetSystemDebugState` checked its pointer, id and size. The console returns `0x80268006` (not initialized) from all three. Each now returns `0x80268006` first when `AudioOut2IsInitialized_nid_no_patch()` is false, as the mastering calls do since #11244, and changes no state. Source: - `sceAudioOut2SetSystemDebugState`: #9838 (https://github.com/boykopovar/AnyPS5/pull/9838) read the export in PS5 firmware 3.20 and 4.03 and states that the console checks `0x80268006` first, before the null pointer, id and size checks. It left the check out only because `sceAudioOut2Initialize` kept no state on `main` then. - `sceAudioOut2EnableChat` and `sceAudioOut2DisableChat`: the debt entry (f7a7be1a2) records that both PS5 exports take no arguments and return `0x80268006` before AudioOut2 initialization, then call the system chat service with selector 3. Neither has another check before the service call, so the order question does not arise. The two debt entries lose the closed clause; the rest stays open: the debug state is still only traced, id `0x20` with a 4-byte param still throws, and the chat calls still have no chat service behind them. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> Windows 11 Pro 26200, WinLibs GCC 15.2.0 r7, Ninja, Release, `-DBUILD_TESTING=ON`, on `main` 750cf6cf48. - `audio_out2_latency` (existing test, new `TestSystemBeforeInitialize` run in `main` before `sceAudioOut2Initialize`): `sceAudioOut2SetSystemDebugState` with the loudness state, a null pointer, id 2, id 1 with size 4, id `0x20` with size 4 and id 1 with a null param all return `0x80268006` (the last two throw after initialization, so the check comes first), and `sceAudioOut2EnableChat` and `sceAudioOut2DisableChat` return `0x80268006`. The existing `TestSetSystemDebugState` and `TestEnableChat` that run after initialization pass unchanged. - With `AudioOut2System.cpp` from `main` and the new test kept, `audio_out2_latency` fails on its first new check (`a debug state before AudioOut2 initialization is refused`). With only the `sceAudioOut2EnableChat` guard removed it fails on `enabling chat before AudioOut2 initialization is refused`, and with only the `sceAudioOut2DisableChat` guard removed on `disabling chat before AudioOut2 initialization is refused`. With the change it passes. - `ctest --test-dir build -R "audio" --output-on-failure`, three runs: 56/56 passed each time. - `ctest --test-dir build -R "public_headers" --output-on-failure`: 65/65 passed. - `ctest --test-dir build -j 8 --output-on-failure`: 2811/2811 passed, 11 of them skipped (Vulkan feature, SDL pad and fopen tests that skip on this machine, none in libSceAudioOut). - No build warnings in the changed files. - `python tools/check_conventions.py --base origin/main` passes; `git diff --check` is clean. - `python tools/pr_overlap.py --branch fix/audioout2-chat-debug-state-not-initialized`: no overlap; #5021 conflicts with `main` and only shares `docs/dev/debt/libSceAudioOut.md`, so it could not be compared. Linux not tested. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [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: <!-- #PR, or none --> none - [x] Fixes: <!-- issue it closes as Fixes #N, or none --> none - [x] Unblocks: <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> none - [x] GPUs tested: <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> n/a - [x] AI-assisted: <!-- yes / no --> yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
MarcZX10 commented 2026-10-28 13:53:09 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-28T13:53:09Z.

Review: COMMENTED


I reviewed the exact head 9f6c3527ed. The initialization check is placed before pointer/id/size validation and before changing either chat flag, matching the cited console check order and preserving post-initialization behavior. The regression exercises the pointer/id/size precedence cases and both chat calls before initialization, while existing initialized-path tests remain in place. The hosted Windows job and repository checks pass. I could not independently rerun the Windows-only audio suite from this Linux environment; the detailed red-green and full-suite results in the PR description are author-reported. I found no concrete defect in the diff.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5683750860 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12425#pullrequestreview-5683750860). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-28T13:53:09Z. **Review:** COMMENTED --- I reviewed the exact head `9f6c3527ed`. The initialization check is placed before pointer/id/size validation and before changing either chat flag, matching the cited console check order and preserving post-initialization behavior. The regression exercises the pointer/id/size precedence cases and both chat calls before initialization, while existing initialized-path tests remain in place. The hosted Windows job and repository checks pass. I could not independently rerun the Windows-only audio suite from this Linux environment; the detailed red-green and full-suite results in the PR description are author-reported. I found no concrete defect in the diff.
MarcZX10 commented 2026-10-28 15:53:53 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-28T15:53:53Z.

Review: APPROVED


Reviewed exact head 9f6c3527ed5f528f77d3f7061e0fd505e9f19193. The three exports now gate on the tracked AudioOut2 initialization state before argument validation or mutating chat state, matching the console check order recorded from firmware 3.20/4.03 and the existing debt evidence. The focused regression covers null/invalid debug-state inputs and both chat calls before initialization; initialized behavior remains covered by the existing suite. My earlier QEMU run of audio_out2_latency_tests exited successfully; hosted Windows and policy checks now pass. I did not run the Windows-only audio tests locally and make no hardware claim. I found no blocking issue.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5685622997 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12425#pullrequestreview-5685622997). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-28T15:53:53Z. **Review:** APPROVED --- Reviewed exact head `9f6c3527ed5f528f77d3f7061e0fd505e9f19193`. The three exports now gate on the tracked AudioOut2 initialization state before argument validation or mutating chat state, matching the console check order recorded from firmware 3.20/4.03 and the existing debt evidence. The focused regression covers null/invalid debug-state inputs and both chat calls before initialization; initialized behavior remains covered by the existing suite. My earlier QEMU run of `audio_out2_latency_tests` exited successfully; hosted Windows and policy checks now pass. I did not run the Windows-only audio tests locally and make no hardware claim. I found no blocking issue.
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!12425
No description provided.