Skip to content

feat(libSceAudioOut): answer the legacy mastering calls without a mastering stage - #8525

Merged
adriadam10 merged 9 commits into
boykopovar:mainfrom
MarrasFederico:feat/audio-out-mastering
Oct 24, 2026
Merged

adriadam10 merged 9 commits into
boykopovar:mainfrom
MarrasFederico:feat/audio-out-mastering

Conversation

@MarrasFederico

@MarrasFederico MarrasFederico commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

What

The legacy mastering calls sceAudioOutMasteringInit, SetParam, GetState and Term threw not implemented, and their debt entries listed the signatures as unknown. SharpProspero AudioOut.cs documents them:

  • Init(uint flags) with SwapEqCompressor (bit 0);
  • SetParam(header*, uint flags) with the default params id 1;
  • GetState(header*) with the default states id 1, which writes the compressor input RMS and gain reduction and the limiter input, output and gain peaks;
  • Term().

The two default header identifiers are documented separately in AudioOut.cs lines 243–247.

Its AudioOutMastering wrapper reads those meters at offsets 32, 128, 240, 272 and 304 of a 336-byte struct, which match the repo's AudioOut2MasteringStates; static_asserts pin them.

AnyPS5 has no mastering stage, so these calls follow their AudioOut2 counterparts, next to which they now live:

  • Init and Term keep no state and return 0 for flags 0. Term is listed under Silent stubs.
  • SetParam accepts params id 1 with flags 0 and records nothing; only the 4-byte header is read.
  • GetState for states id 1 zeroes the five meter arrays and leaves every other byte untouched.
  • What throws: any non-zero flags, null pointers and other ids. SharpProspero documents bit 0 as SwapEqCompressor, but shadPS4's PS4 stub rejects any non-zero Init flags with 0x80260201, so its effect is disputed.

The four "unknown signature" entries are replaced by entries recording what is unverified: the disputed bit 0, repeated or unmatched Init/Term, SetParam or GetState before Init, the id 1 parameter layout, and whether a console reports zero meters for an idle chain.

Tested

Ubuntu 26.04.1, kernel 7.0.0-38, GCC 15.2.0, Release, full build with BUILD_TESTING=ON. Windows was not compiled. No title was run.

  • audio_out2_latency, new legacy-mastering cases:
    • Init with flags 0 returns 0, and any other flags, bit 0 included, throw.
    • SetParam with id 1 and flags 0 returns 0 and leaves the parameters unchanged; another id, any other flags and null throw.
    • GetState with id 1 zeroes exactly the five meter arrays of a 0xA5-filled struct, and another id or null throws without writing.
    • Term returns 0.
  • The test fails on main, where the calls throw. Accepting Init flag bit 0, missing one meter array, or accepting another params or states id makes it fail.
  • All 41 tests matching audio_out pass.
  • tools/check_conventions.py --base origin/main passes. tools/pr_overlap.py finds no conflicting lines. It could not compare feat(aot): consolidate native ARM64 compiler, runtime and consumers #5021 and feat(libSceAudioOut): implement sceAudioOutGetSystemState #5965, which conflict with main; neither touches the mastering calls.

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

@github-actions

github-actions Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Progress report (9d6adeb → cf06f64)

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

✅ 1 implemented
Library Name
libSceAudioOut sceAudioOutMasteringTerm
⚪ 1 behaviourally empty (constant return or throw)
Library Name
libSceAudioOut sceAudioOutMasteringTerm

@github-actions

github-actions Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
PR 10179 docs/dev/debt/libSceAudioOut.md L5

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 core/libs/prx/libSceAudioOut/src/Unimplemented.cpp
docs/dev/debt/libSceAudioOut.md
PR 9818 core/libs/prx/libSceAudioOut/src/AudioOut2Mastering.cpp
PR 9826 core/libs/prx/libSceAudioOut/src/AudioOut2Mastering.cpp

@nikowolf123

Copy link
Copy Markdown
Contributor

sceAudioOutMasteringInit(1) returns 0 here (AudioOut2Mastering.cpp#L39), and the new test requires it (AudioOut2Latency.cpp#L123). The debt entry (libSceAudioOut.md#L126) and the PR text both say the sources document no error code for these calls. shadPS4 does document one. Its sceAudioOutMasteringInit returns ORBIS_AUDIO_OUT_ERROR_MASTERING_INVALID_API_PARAM (0x80260201) for any non-zero flags, and audioout_error.h lists the legacy mastering codes 0x80260200 to 0x80260204. Neither source is a console measurement, and shadPS4's function is a PS4 stub. Still, they disagree on exactly the input the test pins: SharpProspero documents SwapEqCompressor as an Init flag, and shadPS4 rejects it.

I would take one of two routes. The first is to throw for bit 0 as well, as sceAudioOut2MasteringInit already does for flags it cannot confirm, and to change the test so it expects a throw for flags 1:

int APS5_VABI sceAudioOutMasteringInit(uint32_t flags) {
    if (flags != 0) NotImplemented_nid_no_patch(__func__);
    return 0;
}

The second is to keep accepting bit 0 and replace "the sources document no error code" in the entry with what shadPS4 shows: 0x80260201 for any non-zero Init flags, plus 0x80260203 (not initialized) and 0x80260204 (invalid states id). Since a not-initialized code exists, GetState before Init could also be listed as unknown, next to SetParam before Init.

One smaller point: the SharpProspero link in the entry and the PR text (AudioOut.cs#L106-L114) shows only the flags enum. The signatures are at L312-L344, and the id 1 constants are at L243-L247.

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

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 their versions from the PR's merge base (acda0b06f9), 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).

@MarrasFederico

Copy link
Copy Markdown
Contributor Author

@nikowolf123 thanks, I took the first route in bef2578 (on top of current main):

  • sceAudioOutMasteringInit and sceAudioOutMasteringSetParam now throw for any non-zero flags, SwapEqCompressor included, and the test expects that;
  • the debt entry says why: SharpProspero documents bit 0, while shadPS4's stub rejects any non-zero Init flags with 0x80260201;
  • the links now point at the signatures (AudioOut.cs#L312-L344) and the id constants (#L243-L247).

GetState and SetParam before Init are listed as unknown too. All 41 audio_out tests pass.

@xXPBSXx thanks for the Windows run.

@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 MarrasFederico — 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 the legacy mastering calls here. I propose #8525 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.

@MarrasFederico

Copy link
Copy Markdown
Contributor Author

@xdCloudy agreed: #8525 lands first and #9541 rebases afterward. I compared the diffs, and the exports are distinct. In Unimplemented.cpp, #8525 only removes the legacy mastering stubs (sceAudioOutMasteringInit, sceAudioOutMasteringSetParam and their neighbours), while #9541 adds the sceAudioDeviceControlGet/Set declarations. The two touch neighbouring lines in docs/dev/debt/libSceAudioOut.md, so the rebase should only need that list merged. Thanks for coordinating.

@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 22, 2026
…ering

# Conflicts:
#	docs/dev/debt/libSceAudioOut.md
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 23, 2026
@adriadam10
adriadam10 merged commit 87666fc into boykopovar:main Oct 24, 2026
12 checks passed
@adriadam10

Copy link
Copy Markdown
Collaborator

Checked the signatures, default ids (1) and meter offsets (32/128/240/272/304 in the 336-byte states struct) against SharpProspero at the cited commit; the static_asserts pin the offsets. The new test cases fail on main (the calls threw), flags bit 0 and other ids throw as the debt entry explains, and Term is listed under Silent stubs. Windows run by @xXPBSXx confirmed; merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants