fix(libSceAudioOut): track mastering initialization as the console does #9027

Merged
hypermoist merged 3 commits from upstream-pr/9027 into main 2026-10-23 11:54:35 +00:00
hypermoist commented 2026-10-21 10:04:19 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by hypermoist on 2026-10-21T10:04:19Z.


What

sceAudioOut2MasteringInit threw for any non-zero flags. sceAudioOut2MasteringInitEx accepts 0 and bit 31 since #9349 and throws for any other flag. This PR replaces that body with the shared Init/InitEx routine below, which returns 0x80268201 for those flags. Term, GetState and SetParam accepted calls in any state. All three of my title dumps import sceAudioOut2MasteringInit (PPSA03671, PPSA08427, PPSA29340).

In the decrypted PS5 12.00 libSceAudioOut, both Init exports (XHl38ZNknbs 0x22660 and 7ukE-Yrzqog 0x22650) jump into one routine at 0x22360. InitEx passes a flag that lets bit 31 through. The module keeps one mastering-initialized byte. Behaviour, with what this PR reproduces:

Call Console Here
Init / InitEx, already initialized returns 0 before looking at the flags Same
Init, flags ≠ 0 0x80268201 Same; it threw before
InitEx, flags with any bit other than 31 0x80268201. Bit 31 is passed to the audio server as a mastering mode (SDK ≥ 3.0) Same check; the mode is not used, as there is no mastering stage
Term (2bbBBOkH4CY 0x22690) before Init 0x80268203; otherwise clears the flag and returns 0 (no count) Same; it always returned 0 before
GetState (VZidxi2cYh0 0x22da0) 0x80268203 before Init, checked before the pointer. A null state gives 0x8026800C Same; a null state gave 0x80268201 before
SetParam (v8iOE+j8a5o 0x228e0) 0x80268203 before Init. Then 0x80268201 for a null parameter, then 0x80268205 for flags above 1 Same; only the null check existed before

The console also returns 0x80268006 from all of these before sceAudioOut2Initialize. This project does not track that initialization, so it is left out and noted in the debt file. The console's output/user checks and its audio-server failures (0x80268000, -1) are not reproduced.

The existing debt entry noted that PPSA01289 calls Init twice and then Term twice and only logs a non-zero result. By the module, that second Term gets 0x80268203. audio_out2_latency asserted that it returns 0, so the test now follows the module.

The code is written from the observed behaviour; nothing from the module is copied.

Tested

Linux (CachyOS, GCC, Release). audio_out2_latency now checks:

  • every call before Init;
  • the flag checks of both Init calls;
  • the already-initialized early return;
  • that initializations are not counted;
  • GetState's null code;
  • SetParam's check order and flag limit.

All 41 audio_out* tests pass.

Each negative control fails the test:

  • Term always returning 0 fails "termination before initialization is refused";
  • checking flags before the initialized flag fails "an initialized stage returns 0 before the flags are checked".

tools/check_conventions.py is clean. Three-way merges with every open PR that touches these four files add no conflicts (#5021, #5965, #6879, #8098, #8525, #8652, #8693). #8525 implements the legacy sceAudioOutMastering* calls in the same files and does not use these functions.

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: PPSA03671, PPSA08427 and PPSA29340 import sceAudioOut2MasteringInit; none was run with this change
  • GPUs tested: n/a
  • AI-assisted: yes

🤖 Generated with Claude Code

https://claude.ai/code/session_01RbLgECLQ2bpDM7oe2urGZK

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4949821028 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9027). Originally posted by [hypermoist](https://github.com/hypermoist) on 2026-10-21T10:04:19Z. --- ### What `sceAudioOut2MasteringInit` threw for any non-zero flags. `sceAudioOut2MasteringInitEx` accepts 0 and bit 31 since #9349 and throws for any other flag. This PR replaces that body with the shared Init/InitEx routine below, which returns `0x80268201` for those flags. Term, GetState and SetParam accepted calls in any state. All three of my title dumps import `sceAudioOut2MasteringInit` (PPSA03671, PPSA08427, PPSA29340). In the decrypted PS5 12.00 `libSceAudioOut`, both Init exports (`XHl38ZNknbs` 0x22660 and `7ukE-Yrzqog` 0x22650) jump into one routine at 0x22360. InitEx passes a flag that lets bit 31 through. The module keeps one mastering-initialized byte. Behaviour, with what this PR reproduces: | Call | Console | Here | |---|---|---| | Init / InitEx, already initialized | returns 0 before looking at the flags | Same | | Init, flags ≠ 0 | `0x80268201` | Same; it threw before | | InitEx, flags with any bit other than 31 | `0x80268201`. Bit 31 is passed to the audio server as a mastering mode (SDK ≥ 3.0) | Same check; the mode is not used, as there is no mastering stage | | Term (`2bbBBOkH4CY` 0x22690) before Init | `0x80268203`; otherwise clears the flag and returns 0 (no count) | Same; it always returned 0 before | | GetState (`VZidxi2cYh0` 0x22da0) | `0x80268203` before Init, checked before the pointer. A null state gives `0x8026800C` | Same; a null state gave `0x80268201` before | | SetParam (`v8iOE+j8a5o` 0x228e0) | `0x80268203` before Init. Then `0x80268201` for a null parameter, then `0x80268205` for flags above 1 | Same; only the null check existed before | The console also returns `0x80268006` from all of these before `sceAudioOut2Initialize`. This project does not track that initialization, so it is left out and noted in the debt file. The console's `output`/`user` checks and its audio-server failures (`0x80268000`, -1) are not reproduced. The existing debt entry noted that PPSA01289 calls Init twice and then Term twice and only logs a non-zero result. By the module, that second Term gets `0x80268203`. `audio_out2_latency` asserted that it returns 0, so the test now follows the module. The code is written from the observed behaviour; nothing from the module is copied. ### Tested Linux (CachyOS, GCC, Release). `audio_out2_latency` now checks: - every call before Init; - the flag checks of both Init calls; - the already-initialized early return; - that initializations are not counted; - GetState's null code; - SetParam's check order and flag limit. All 41 `audio_out*` tests pass. Each negative control fails the test: - Term always returning 0 fails "termination before initialization is refused"; - checking flags before the initialized flag fails "an initialized stage returns 0 before the flags are checked". `tools/check_conventions.py` is clean. Three-way merges with every open PR that touches these four files add no conflicts (#5021, #5965, #6879, #8098, #8525, #8652, #8693). #8525 implements the legacy `sceAudioOutMastering*` calls in the same files and does not use these functions. ### 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: PPSA03671, PPSA08427 and PPSA29340 import `sceAudioOut2MasteringInit`; none was run with this change - [x] GPUs tested: n/a - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01RbLgECLQ2bpDM7oe2urGZK
xXPBSXx commented 2026-10-21 13:44:01 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-21T13:44:01Z.


Linux data point for 5a7ef76100: WSL2 Ubuntu 24.04 (virtualised kernel, not bare-metal Linux), GCC 13.3.0, Release, BUILD_TESTING=ON, PR head alone (not merged onto main) (its merge-base is 27c88a8d7).

  • With the PR: ctest -R '^audio_out2_latency$' passes 3 of 3.
  • With the production files of the PR restored to the merge-base (AudioOut2Mastering.cpp and Unimplemented.cpp (libSceAudioOut/src); the PR's tests kept): fails (Subprocess aborted).
    Not tested: macOS, Windows, a title run.
    AI-assisted (Claude Code).
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6317610373 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9027#issuecomment-6317610373). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-21T13:44:01Z. --- Linux data point for `5a7ef76100`: WSL2 Ubuntu 24.04 (virtualised kernel, not bare-metal Linux), GCC 13.3.0, Release, `BUILD_TESTING=ON`, PR head alone (not merged onto `main`) (its merge-base is `27c88a8d7`). - With the PR: `ctest -R '^audio_out2_latency$'` passes 3 of 3. - With the production files of the PR restored to the merge-base (`AudioOut2Mastering.cpp and Unimplemented.cpp (libSceAudioOut/src)`; the PR's tests kept): fails (`Subprocess aborted`). Not tested: macOS, Windows, a title run. AI-assisted (Claude Code).
xXPBSXx commented 2026-10-21 15:42:40 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-21T15:42:40Z.


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_latency_tests; ctest -N -R audio_out2_latency lists exactly one test.

PR head tested: 5a7ef7610021fb35ac1f44a5ba35885cf9368a1b.

Results (3 runs each):

  • PR head: audio_out2_latency passes 3/3.
  • Baseline: I kept the PR's test and replaced only these production files: core/libs/prx/libSceAudioOut/src/AudioOut2Mastering.cpp, core/libs/prx/libSceAudioOut/src/Unimplemented.cpp with the version from the PR's merge base (27c88a8d75), then rebuilt. The test fails 3/3 (exit 0xc0000409). I restored the PR's files afterwards.

GPU: the run output has no Selected GPU line; no GPU claim is made.

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:6320045485 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9027#issuecomment-6320045485). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-21T15:42:40Z. --- 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_latency_tests`; `ctest -N -R audio_out2_latency` lists exactly one test. **PR head tested:** `5a7ef7610021fb35ac1f44a5ba35885cf9368a1b`. **Results (3 runs each):** - PR head: `audio_out2_latency` passes 3/3. - Baseline: I kept the PR's test and replaced only these production files: `core/libs/prx/libSceAudioOut/src/AudioOut2Mastering.cpp`, `core/libs/prx/libSceAudioOut/src/Unimplemented.cpp` with the version from the PR's merge base (`27c88a8d75`), then rebuilt. The test fails 3/3 (exit 0xc0000409). I restored the PR's files afterwards. **GPU:** the run output has no `Selected GPU` line; no GPU claim is made. **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).
xdCloudy commented 2026-10-22 01:01:48 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by xdCloudy on 2026-10-22T01:01:48Z.


Hi — MarcZX10's review on my #9541 found that both PRs touch libSceAudioOut/src/Unimplemented.cpp and docs/dev/debt/libSceAudioOut.md, so the overlap scanner cannot compare the old-base branch cleanly. My two declarations are distinct from sceAudioOut2MasteringInitEx. I propose #9027 lands before #9541; I’ll record it as a prerequisite and rebase/update #9541 afterward. Please let me know if you agree with that order.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6330102368 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9027#issuecomment-6330102368). Originally posted by [xdCloudy](https://github.com/xdCloudy) on 2026-10-22T01:01:48Z. --- Hi — MarcZX10's review on my #9541 found that both PRs touch `libSceAudioOut/src/Unimplemented.cpp` and `docs/dev/debt/libSceAudioOut.md`, so the overlap scanner cannot compare the old-base branch cleanly. My two declarations are distinct from `sceAudioOut2MasteringInitEx`. I propose #9027 lands before #9541; I’ll record it as a prerequisite and rebase/update #9541 afterward. Please let me know if you agree with that order.
hypermoist commented 2026-10-22 01:30:20 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by hypermoist on 2026-10-22T01:30:20Z.


@xdCloudy agreed: #9027 first, then #9541 rebased on top. I've merged main into this branch (7ef7653590), so it's mergeable again. The only conflict was the debt entry: I kept main's new sceAudioOutExGetMonitorInfo and sceAudioOut2Set3DLatency lines, and this PR's mastering lines, which replace main's description of the old Init. ctest -R audio_out passes on Linux (41 of 41).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6330478324 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9027#issuecomment-6330478324). Originally posted by [hypermoist](https://github.com/hypermoist) on 2026-10-22T01:30:20Z. --- @xdCloudy agreed: #9027 first, then #9541 rebased on top. I've merged `main` into this branch (7ef7653590), so it's mergeable again. The only conflict was the debt entry: I kept `main`'s new `sceAudioOutExGetMonitorInfo` and `sceAudioOut2Set3DLatency` lines, and this PR's mastering lines, which replace `main`'s description of the old Init. `ctest -R audio_out` passes on Linux (41 of 41).
MarcZX10 commented 2026-10-23 06:16:24 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-23T06:16:24Z.

Review: APPROVED


Reviewed exact current-main head 1cee26eba7766e0db2a3fb9123beacb62db394a3. The shared Init/InitEx routine models the initialized early return, checks distinct Init versus InitEx flag masks, and stores a single initialized state; Term/GetState/SetParam enforce the measured state/error order. Tests now cover pre-init calls, flag ordering, repeat initialization, non-counted Term and SetParam validation. The author reports the focused audio_out2_latency test and NID-patched PRX builds passing on Linux and Windows/Wine after merging current main; all 41 audio_out tests passed on Linux before that refresh, and the refreshed focused suite passed. Local diff-check, conventions and main-sync checks pass (3 ahead/0 behind). Product jobs are skipped by policy. #9818 and #9826 also touch the old Init flag path but request broad unsupported stub changes; their current reviews ask to retain throws. This review considers this evidence-backed implementation independently complete; if either shared-file PR is later revised/merged, preserve these measured semantics during integration. Approval applies to this exact head.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5624631134 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9027#pullrequestreview-5624631134). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-23T06:16:24Z. **Review:** APPROVED --- Reviewed exact current-main head `1cee26eba7766e0db2a3fb9123beacb62db394a3`. The shared Init/InitEx routine models the initialized early return, checks distinct Init versus InitEx flag masks, and stores a single initialized state; Term/GetState/SetParam enforce the measured state/error order. Tests now cover pre-init calls, flag ordering, repeat initialization, non-counted Term and SetParam validation. The author reports the focused `audio_out2_latency` test and NID-patched PRX builds passing on Linux and Windows/Wine after merging current main; all 41 audio_out tests passed on Linux before that refresh, and the refreshed focused suite passed. Local diff-check, conventions and main-sync checks pass (3 ahead/0 behind). Product jobs are skipped by policy. #9818 and #9826 also touch the old Init flag path but request broad unsupported stub changes; their current reviews ask to retain throws. This review considers this evidence-backed implementation independently complete; if either shared-file PR is later revised/merged, preserve these measured semantics during integration. Approval applies to this exact head.
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!9027
No description provided.