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

Merged
MarrasFederico merged 9 commits from upstream-pr/8525 into main 2026-10-24 12:21:13 +00:00
MarrasFederico commented 2026-10-20 15:08:17 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarrasFederico on 2026-10-20T15:08:17Z.


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 #5021 and #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
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4937835866 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8525). Originally posted by [MarrasFederico](https://github.com/MarrasFederico) on 2026-10-20T15:08:17Z. --- ### 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`](https://github.com/SvenGDK/SharpProspero/blob/5dfdb4b0b166e83dc9ae275001afb695f12c7174/src/SharpProspero/Interop/Audio/AudioOut.cs#L312-L344) 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](https://github.com/SvenGDK/SharpProspero/blob/5dfdb4b0b166e83dc9ae275001afb695f12c7174/src/SharpProspero/Interop/Audio/AudioOut.cs#L243-L247). Its [`AudioOutMastering`](https://github.com/SvenGDK/SharpProspero/blob/5dfdb4b0b166e83dc9ae275001afb695f12c7174/src/SharpProspero/Audio/AudioOutMastering.cs#L97-L110) wrapper reads those meters at offsets 32, 128, 240, 272 and 304 of a 336-byte struct, which match the repo's `AudioOut2MasteringStates`; `static_assert`s 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 <!-- 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. --> 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 #5021 and #5965, which conflict with `main`; neither touches the mastering calls. ### 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: none <!-- #PR, or none --> - [x] Fixes: none <!-- issue it closes as Fixes #N, or none --> - [x] Unblocks: none <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> - [x] GPUs tested: n/a <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> - [x] AI-assisted: yes <!-- yes / no -->
nikowolf123 commented 2026-10-20 19:04:58 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by nikowolf123 on 2026-10-20T19:04:58Z.


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.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6298912122 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8525#issuecomment-6298912122). Originally posted by [nikowolf123](https://github.com/nikowolf123) on 2026-10-20T19:04:58Z. --- `sceAudioOutMasteringInit(1)` returns 0 here ([AudioOut2Mastering.cpp#L39](https://github.com/boykopovar/AnyPS5/blob/3817558ef1af4078fef920a245537bb0a061912b/core/libs/prx/libSceAudioOut/src/AudioOut2Mastering.cpp#L39)), and the new test requires it ([AudioOut2Latency.cpp#L123](https://github.com/boykopovar/AnyPS5/blob/3817558ef1af4078fef920a245537bb0a061912b/core/libs/prx/libSceAudioOut/tests/AudioOut2Latency.cpp#L123)). The debt entry ([libSceAudioOut.md#L126](https://github.com/boykopovar/AnyPS5/blob/3817558ef1af4078fef920a245537bb0a061912b/docs/dev/debt/libSceAudioOut.md#L126)) and the PR text both say the sources document no error code for these calls. shadPS4 does document one. Its [`sceAudioOutMasteringInit`](https://github.com/shadps4-emu/shadPS4/blob/8d50471b7dc141dd700b51276b8edd1f293bce26/src/core/libraries/audio/audioout.cpp#L956-L962) returns `ORBIS_AUDIO_OUT_ERROR_MASTERING_INVALID_API_PARAM` (0x80260201) for any non-zero `flags`, and [`audioout_error.h`](https://github.com/shadps4-emu/shadPS4/blob/8d50471b7dc141dd700b51276b8edd1f293bce26/src/core/libraries/audio/audioout_error.h#L30-L34) 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: ```cpp 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](https://github.com/SvenGDK/SharpProspero/blob/5dfdb4b0b166e83dc9ae275001afb695f12c7174/src/SharpProspero/Interop/Audio/AudioOut.cs#L312-L344), and the id 1 constants are at [L243-L247](https://github.com/SvenGDK/SharpProspero/blob/5dfdb4b0b166e83dc9ae275001afb695f12c7174/src/SharpProspero/Interop/Audio/AudioOut.cs#L243-L247).
xXPBSXx commented 2026-10-21 04:48:14 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-21T04:48:14Z.


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

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6308296409 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8525#issuecomment-6308296409). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-21T04:48:14Z. --- 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 commented 2026-10-21 12:33:23 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarrasFederico on 2026-10-21T12:33:23Z.


@nikowolf123 thanks, I took the first route in bef257883 (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.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6315994589 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8525#issuecomment-6315994589). Originally posted by [MarrasFederico](https://github.com/MarrasFederico) on 2026-10-21T12:33:23Z. --- @nikowolf123 thanks, I took the first route in bef257883 (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.
xdCloudy commented 2026-10-22 01:01:36 +00:00 (Migrated from github.com)

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


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.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6330099733 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8525#issuecomment-6330099733). Originally posted by [xdCloudy](https://github.com/xdCloudy) on 2026-10-22T01:01:36Z. --- 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 commented 2026-10-22 04:54:48 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarrasFederico on 2026-10-22T04:54:48Z.


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

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6333047732 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8525#issuecomment-6333047732). Originally posted by [MarrasFederico](https://github.com/MarrasFederico) on 2026-10-22T04:54:48Z. --- @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.
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!8525
No description provided.