Skip to content

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

Merged
oneandonlydean merged 3 commits into
boykopovar:mainfrom
hypermoist:fix/audioout2-mastering-state
Oct 23, 2026
Merged

oneandonlydean merged 3 commits into
boykopovar:mainfrom
hypermoist:fix/audioout2-mastering-state

Conversation

@hypermoist

@hypermoist hypermoist commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

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

The PS5 module keeps one mastering-initialized flag. A repeated
initialization returns 0 before the flags are checked; otherwise
sceAudioOut2MasteringInit accepts only 0 and sceAudioOut2MasteringInitEx
also bit 31, and other flags return 0x80268201. Term, GetState and
SetParam return 0x80268203 before initialization, GetState returns
0x8026800C for a null state and SetParam 0x80268205 for flags above 1.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RbLgECLQ2bpDM7oe2urGZK
@github-actions github-actions Bot added the unblocks title Names a title ID on the Unblocks line label Oct 21, 2026
@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Progress report (0db47b2 → 1cee26e)

📈 System libraries: 45.18% (+0.01%, +2 implemented functions)

✅ 2 implemented
Library Name
libSceAudioOut sceAudioOut2MasteringInit
libSceAudioOut sceAudioOut2MasteringInitEx

@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 5021 docs/dev/debt/libSceAudioOut.md
PR 8652 docs/dev/debt/libSceAudioOut.md
PR 9818 core/libs/prx/libSceAudioOut/src/AudioOut2Mastering.cpp
PR 9826 core/libs/prx/libSceAudioOut/src/AudioOut2Mastering.cpp

@xXPBSXx

xXPBSXx commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

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

xXPBSXx commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

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).

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 21, 2026
@xdCloudy

Copy link
Copy Markdown
Contributor

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.

…ring-state

# Conflicts:
#	docs/dev/debt/libSceAudioOut.md
@hypermoist

Copy link
Copy Markdown
Contributor Author

@xdCloudy agreed: #9027 first, then #9541 rebased on top. I've merged main into this branch (7ef7653), 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).

@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 22, 2026
@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 23, 2026
…ring-state

Keep the shared Init/InitEx validation over the InitEx body from boykopovar#9349.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SNqSvnFwRBz3D76n476yw6
@hypermoist

Copy link
Copy Markdown
Contributor Author

Merged current main (0db47b2) to clear the conflict, in 1cee26e.

What conflicted. #9349 (@MarcZX10) landed an sceAudioOut2MasteringInitEx that accepts 0 and bit 31 and throws for any other flag. This PR already had InitEx, so three places clashed:

  • the InitEx body;
  • the Init/InitEx cases in AudioOut2Latency.cpp;
  • the InitEx debt lines.

How I resolved it.

  • InitEx body: InitEx keeps this PR's shared routine (the module's 0x22360): it returns 0 once initialized, accepts bit 31, and returns 0x80268201 for any other bit. I removed the second InitEx definition that came from main. This is the case feat(libSceAudioOut): support mastering InitEx flags #9349 left throwing, and the module returns that error for it.
  • Tests: they keep this PR's error-code expectations for Init(1), InitEx(1), InitEx(0x80000001) and the bit-31 path. main also added an errorInvalidPointer constant, which this PR already had, so it now appears once.
  • Debt file: docs/dev/debt/libSceAudioOut.md keeps this PR's combined Init/InitEx entry and main's new sceAudioOut2SetSystemDebugState entry. main's separate InitEx line is dropped, because the combined entry covers it.

The description now says what main has since #9349.

Tests on the merge: audio_out2_latency passes on Linux (GCC 16.2.1) and under Wine (WinLibs GCC 15.2.0), and the NID-patched libSceAudioOut.prx builds on both. On Linux the other eight audio_out2* tests pass too.

Overlap: #9818 and #9826 only change how Init's non-zero-flag path throws, on the line this PR replaces. Whichever lands second takes this PR's version of that line.

🤖 Generated with Claude Code

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 23, 2026
@oneandonlydean oneandonlydean self-assigned this Oct 23, 2026
@oneandonlydean
oneandonlydean merged commit 19d0005 into boykopovar:main Oct 23, 2026
11 of 12 checks passed
oneandonlydean pushed a commit that referenced this pull request Oct 28, 2026
…ioOut2Initialize

The PS5 module read for #9027 returns 0x80268006 from sceAudioOut2MasteringInit,
sceAudioOut2MasteringInitEx, sceAudioOut2MasteringTerm,
sceAudioOut2MasteringGetState and sceAudioOut2MasteringSetParam before
sceAudioOut2Initialize. #9027 left the check out because AudioOut2
initialization was not tracked; AudioOut2IsInitialized_nid_no_patch now
tracks it, so each of these returns 0x80268006 first, before its own
mastering-state and argument checks, and changes no state. The debt entry
drops the closed gap.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs prx unblocks title Names a title ID on the Unblocks line

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants