fix(libSceAudioOut): report not-initialized, null-pointer and flag errors from sceAudioOut2GetSpeakerInfo #8693

Merged
JAB-dev merged 7 commits from upstream-pr/8693 into main 2026-10-24 18:32:15 +00:00
JAB-dev commented 2026-10-20 21:16:07 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by JAB-dev on 2026-10-20T21:16:07Z.


What

sceAudioOut2GetSpeakerInfo now returns the AudioOut2 errors the console returns instead of a made-up code and silent success. Before sceAudioOut2Initialize it returns 0x80268006 (not initialized), a null result pointer returns 0x8026800C (invalid pointer; the repo returned 0x80260502, which is not an AudioOut2 error code), and flags above 1 return 0x80268001 (invalid param) without touching the result. sceAudioOut2Initialize now records that it ran, so the call can tell. The success output is unchanged.

The PS5 SDK declares sceAudioOut2GetSpeakerInfo(SceAudioOut2SpeakerInfo *outInfo, uint32_t flags) and defines flag bit 0, SCE_AUDIO_OUT2_GET_SPEAKER_INFO_FLAG_FOLLOW_HEADPHONE_CONNECT, as the only flag (audio_out2.h), and defines SCE_AUDIO_OUT2_ERROR_INVALID_PARAM as 0x80268001, SCE_AUDIO_OUT2_ERROR_NOT_INITIALIZED as 0x80268006 and SCE_AUDIO_OUT2_ERROR_INVALID_POINTER as 0x8026800C (error.h). PS5 firmware libSceAudioOut 3.20 (vaddr 0x1fab0) and 4.03 (vaddr 0x203f0) check in this order: the module-initialized byte, which the init path sets and the terminate path clears, then a null result pointer, then the flags. Flags above 1 are refused in both branches of the flags check; the other branch, picked by a module global, also refuses flag 1, and that global is not modelled here; the debt entry records it.

No scanned local title imports this function; the change only affects a caller that runs before sceAudioOut2Initialize, passes a null pointer or passes flags above 1, which fail on the console too.

sceAudioOutInit now also initializes AudioOut2. In PS5 firmware 3.20 and 4.03 it calls sceAudioOut2Initialize (after which a second call returns 0x8026000e), and that call is the only thing that sets the flag sceAudioOut2GetSpeakerInfo tests first, so a title that only calls sceAudioOutInit passes the not-initialized check on the console. An independent run of the firmware 13.42 module (thanks to BunnyFl, on this PR) showed the same call. Here sceAudioOutInit still returns 0 on repeated calls. The initialized flag moves into AudioOut.cpp next to it, so the two test targets that build only that file still link.

Tested

Windows 11 x64, MinGW GCC 15.2.0 (WinLibs r7).

  • audio_out2_device_state (existing test, extended): before sceAudioOut2Initialize, a valid call, a null call and a flags-2 call all return 0x80268006 and leave the buffer filled with 0xAB untouched. After it, a null pointer returns 0x8026800C (also with flags 2), flags 2 and 0x80000000 return 0x80268001 with the buffer untouched, flags 1 succeeds with the front pair, and the existing flags-0 checks pass. The expected codes are written out from the SDK header values, not computed by the code under test.
  • On main the test fails: the first call before initialization returns 0 where 0x80268006 is expected, and a null pointer returns 0x80260502.
  • The same test calls sceAudioOutInit and then sceAudioOut2GetSpeakerInfo, which succeeds; with sceAudioOutInit returning 0 without initializing, that check fails. The debt file now records that a repeated sceAudioOutInit returns 0 here against 0x8026000e on the firmware, that a repeated sceAudioOut2Initialize is unmeasured, and that flag 1 is refused below an unidentified per-process libkernel value. All 43 audio_out tests pass, and the convention check and git diff --check pass.

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:4942606137 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8693). Originally posted by [JAB-dev](https://github.com/JAB-dev) on 2026-10-20T21:16:07Z. --- ### What `sceAudioOut2GetSpeakerInfo` now returns the AudioOut2 errors the console returns instead of a made-up code and silent success. Before `sceAudioOut2Initialize` it returns `0x80268006` (not initialized), a null result pointer returns `0x8026800C` (invalid pointer; the repo returned `0x80260502`, which is not an AudioOut2 error code), and flags above 1 return `0x80268001` (invalid param) without touching the result. `sceAudioOut2Initialize` now records that it ran, so the call can tell. The success output is unchanged. The PS5 SDK declares `sceAudioOut2GetSpeakerInfo(SceAudioOut2SpeakerInfo *outInfo, uint32_t flags)` and defines flag bit 0, `SCE_AUDIO_OUT2_GET_SPEAKER_INFO_FLAG_FOLLOW_HEADPHONE_CONNECT`, as the only flag (`audio_out2.h`), and defines `SCE_AUDIO_OUT2_ERROR_INVALID_PARAM` as 0x80268001, `SCE_AUDIO_OUT2_ERROR_NOT_INITIALIZED` as 0x80268006 and `SCE_AUDIO_OUT2_ERROR_INVALID_POINTER` as 0x8026800C (`error.h`). PS5 firmware `libSceAudioOut` 3.20 (vaddr 0x1fab0) and 4.03 (vaddr 0x203f0) check in this order: the module-initialized byte, which the init path sets and the terminate path clears, then a null result pointer, then the flags. Flags above 1 are refused in both branches of the flags check; the other branch, picked by a module global, also refuses flag 1, and that global is not modelled here; the debt entry records it. No scanned local title imports this function; the change only affects a caller that runs before `sceAudioOut2Initialize`, passes a null pointer or passes flags above 1, which fail on the console too. `sceAudioOutInit` now also initializes AudioOut2. In PS5 firmware 3.20 and 4.03 it calls `sceAudioOut2Initialize` (after which a second call returns `0x8026000e`), and that call is the only thing that sets the flag `sceAudioOut2GetSpeakerInfo` tests first, so a title that only calls `sceAudioOutInit` passes the not-initialized check on the console. An independent run of the firmware 13.42 module (thanks to BunnyFl, on this PR) showed the same call. Here `sceAudioOutInit` still returns 0 on repeated calls. The initialized flag moves into `AudioOut.cpp` next to it, so the two test targets that build only that file still link. ### Tested Windows 11 x64, MinGW GCC 15.2.0 (WinLibs r7). - `audio_out2_device_state` (existing test, extended): before `sceAudioOut2Initialize`, a valid call, a null call and a flags-2 call all return `0x80268006` and leave the buffer filled with 0xAB untouched. After it, a null pointer returns `0x8026800C` (also with flags 2), flags 2 and `0x80000000` return `0x80268001` with the buffer untouched, flags 1 succeeds with the front pair, and the existing flags-0 checks pass. The expected codes are written out from the SDK header values, not computed by the code under test. - On `main` the test fails: the first call before initialization returns 0 where `0x80268006` is expected, and a null pointer returns `0x80260502`. - The same test calls `sceAudioOutInit` and then `sceAudioOut2GetSpeakerInfo`, which succeeds; with `sceAudioOutInit` returning 0 without initializing, that check fails. The debt file now records that a repeated `sceAudioOutInit` returns 0 here against `0x8026000e` on the firmware, that a repeated `sceAudioOut2Initialize` is unmeasured, and that flag 1 is refused below an unidentified per-process libkernel value. All 43 `audio_out` tests pass, and the convention check and `git diff --check` pass. 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)
xXPBSXx commented 2026-10-21 05:17:26 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-21T05:17:26Z.


Independent Windows run of this PR (data only).

Environment: Windows 10 Pro 10.0.19045, Ryzen 7 5800X3D, WinLibs GCC 15.2.0 r7 (MinGW-w64 UCRT), Release, BUILD_TESTING=ON. Merge-tree of the PR head against main is clean. I built only audio_out2_device_state_tests; ctest -N -R audio_out2_device_state lists exactly one test.

Results (3 runs each):

  • PR head: audio_out2_device_state passes 3/3.
  • Baseline: I kept the PR's test and replaced only these production files: core/libs/prx/libSceAudioOut/src/AudioOut2Internal.hpp, core/libs/prx/libSceAudioOut/src/AudioOut2SpeakerArray.cpp, core/libs/prx/libSceAudioOut/src/AudioOut2System.cpp with the version from the PR's merge base (73b6a4cc71), then rebuilt. The test fails 3/3 (exit 0xc0000409). I restored the PR's files afterwards.

Not run: other platforms, the other tests in the same family, the full repository CTest, and any title or console run.

AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6308658008 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8693#issuecomment-6308658008). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-21T05:17:26Z. --- Independent Windows run of this PR (data only). **Environment:** Windows 10 Pro 10.0.19045, Ryzen 7 5800X3D, WinLibs GCC 15.2.0 r7 (MinGW-w64 UCRT), Release, BUILD_TESTING=ON. Merge-tree of the PR head against `main` is clean. I built only `audio_out2_device_state_tests`; `ctest -N -R audio_out2_device_state` lists exactly one test. **Results (3 runs each):** - PR head: `audio_out2_device_state` passes 3/3. - Baseline: I kept the PR's test and replaced only these production files: `core/libs/prx/libSceAudioOut/src/AudioOut2Internal.hpp`, `core/libs/prx/libSceAudioOut/src/AudioOut2SpeakerArray.cpp`, `core/libs/prx/libSceAudioOut/src/AudioOut2System.cpp` with the version from the PR's merge base (`73b6a4cc71`), then rebuilt. The test fails 3/3 (exit 0xc0000409). I restored the PR's files afterwards. **Not run:** other platforms, the other tests in the same family, the full repository CTest, and any title or console run. AI-assisted (Claude Code).
xXPBSXx commented 2026-10-21 09:45:24 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-21T09:45:24Z.


Linux data point for 4b0c16a173: WSL2 Ubuntu 24.04 (a virtualised kernel, not bare-metal Linux), GCC 13.3.0, Release, BUILD_TESTING=ON, PR head alone (not merged onto main).

  • With the PR: ctest -R '^audio_out2_device_state$' passes 3 of 3.
  • With AudioOut2Internal.hpp, AudioOut2SpeakerArray.cpp and AudioOut2System.cpp restored to the merge-base (new test cases kept): fails (Subprocess aborted).
    Not tested: macOS, Windows, a title run.
    AI-assisted (Claude Code).
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6312963821 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8693#issuecomment-6312963821). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-21T09:45:24Z. --- Linux data point for `4b0c16a173`: WSL2 Ubuntu 24.04 (a virtualised kernel, not bare-metal Linux), GCC 13.3.0, Release, `BUILD_TESTING=ON`, PR head alone (not merged onto `main`). - With the PR: `ctest -R '^audio_out2_device_state$'` passes 3 of 3. - With `AudioOut2Internal.hpp`, `AudioOut2SpeakerArray.cpp` and `AudioOut2System.cpp` restored to the merge-base (new test cases kept): fails (`Subprocess aborted`). Not tested: macOS, Windows, a title run. AI-assisted (Claude Code).
harisibrar1 commented 2026-10-24 15:32:44 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by harisibrar1 on 2026-10-24T15:32:44Z.

Review: COMMENTED


Checked against main b607bfdc8b and main's libSceAudioOut debt file:

  • The three codes and their order match what main's debt entry already records from a PS5 (docs/dev/debt/libSceAudioOut.md:31: 0x80268006 before init, 0x80268001 for flags above 1, 0x8026800C for a null pointer), and BunnyFl's 13.42 run. The branch also merges cleanly with current main.
  • You mention a second sceAudioOutInit returns 0 here where the firmware returns 0x8026000e. Could that go into docs/dev/debt/libSceAudioOut.md? Right now no entry covers it.
  • libSceAudioOut/tests/AudioOut2DeviceState.cpp:159-160 calls sceAudioOutInit() (which now initializes AudioOut2) and then requires sceAudioOut2Initialize() == 0. Is a repeated sceAudioOut2Initialize known to return 0 on the console? If not, I'd drop that assertion or record the repeat behaviour as unmeasured in the debt file.
  • Small follow-on: main's MasteringInit debt line (:16) says the 0x80268006 check isn't returned "since that initialization is not tracked". With this PR it is tracked, so that reason no longer holds.
  • Nit: the debt text calls the flag-1 selector a "module-global threshold". BunnyFl found a per-process value from libkernel with the boundary between 0x14FFFFF and 0x1500000, which might be worth recording as-is.

Reviewed with AI assistance (Claude Code); the checks above were run locally on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5638796127 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8693#pullrequestreview-5638796127). Originally posted by [harisibrar1](https://github.com/harisibrar1) on 2026-10-24T15:32:44Z. **Review:** COMMENTED --- Checked against main b607bfdc8b and main's libSceAudioOut debt file: - The three codes and their order match what main's debt entry already records from a PS5 (docs/dev/debt/libSceAudioOut.md:31: 0x80268006 before init, 0x80268001 for flags above 1, 0x8026800C for a null pointer), and BunnyFl's 13.42 run. The branch also merges cleanly with current main. - You mention a second `sceAudioOutInit` returns 0 here where the firmware returns `0x8026000e`. Could that go into docs/dev/debt/libSceAudioOut.md? Right now no entry covers it. - `libSceAudioOut/tests/AudioOut2DeviceState.cpp:159-160` calls `sceAudioOutInit()` (which now initializes AudioOut2) and then requires `sceAudioOut2Initialize() == 0`. Is a repeated `sceAudioOut2Initialize` known to return 0 on the console? If not, I'd drop that assertion or record the repeat behaviour as unmeasured in the debt file. - Small follow-on: main's MasteringInit debt line (:16) says the 0x80268006 check isn't returned "since that initialization is not tracked". With this PR it is tracked, so that reason no longer holds. - Nit: the debt text calls the flag-1 selector a "module-global threshold". BunnyFl found a per-process value from libkernel with the boundary between 0x14FFFFF and 0x1500000, which might be worth recording as-is. Reviewed with AI assistance (Claude Code); the checks above were run locally on my machine.
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!8693
No description provided.