feat(libSceAudioOut): implement sceAudioOutGetSystemState #5965

Merged
bcortezf merged 2 commits from upstream-pr/5965 into main 2026-10-23 19:52:51 +00:00
bcortezf commented 2026-10-14 17:21:48 +00:00 (Migrated from github.com)

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


What

Red Dead Redemption (PPSA30528) imports sceAudioOutGetSystemState (NID R5hemoKKID8) and fails to load without it:

FAIL: unresolved ELF import R5hemoKKID8 from libSceAudioOut.prx

This PR adds it:

  • Arguments and state: it takes a pointer to a 32-byte system state (float loudness, 4 reserved bytes, 3 reserved 64-bit words, checked by a static_assert) and reports a loudness of 0.0f.
  • Null pointer: returns 0x80260004, like the other AudioOut calls.

The layout follows shadPS4's OrbisAudioOutSystemState and SharpProspero's SceAudioOutSystemState (Size = 32), not a console measurement. The debt entry in docs/dev/debt/libSceAudioOut.md records that, and that the constant 0.0f is unconfirmed (SharpProspero documents loudness in LKFS) and that shadPS4's NOT_INIT before sceAudioOutInit is not modelled.

A unit test (audio_out_system_state) checks the result, the loudness and the null pointer.

Tested

Windows 11 (10.0.26200), MinGW build, on current main (a6dcea927) + this commit (abd3af907)

  • Unit test: ctest -R audio_out_system_state passes.
  • Conventions: python3 tools/check_conventions.py --base origin/main passes.
  • PPSA30528: executable converted again with this branch's relinker, libs from this branch only, no local workarounds: the title loads past the import and reaches gameplay (Blackwater, screenshot attached).

Not tested: Linux/macOS.

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
  • Unblocks: PPSA30528 (Red Dead Redemption): it does not load without this export
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4861716279 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5965). Originally posted by [bcortezf](https://github.com/bcortezf) on 2026-10-14T17:21:48Z. --- ### What Red Dead Redemption (PPSA30528) imports `sceAudioOutGetSystemState` (NID `R5hemoKKID8`) and fails to load without it: ``` FAIL: unresolved ELF import R5hemoKKID8 from libSceAudioOut.prx ``` This PR adds it: - **Arguments and state:** it takes a pointer to a 32-byte system state (`float loudness`, 4 reserved bytes, 3 reserved 64-bit words, checked by a `static_assert`) and reports a loudness of `0.0f`. - **Null pointer:** returns `0x80260004`, like the other AudioOut calls. The layout follows shadPS4's `OrbisAudioOutSystemState` and SharpProspero's `SceAudioOutSystemState` (`Size = 32`), not a console measurement. The debt entry in `docs/dev/debt/libSceAudioOut.md` records that, and that the constant `0.0f` is unconfirmed (SharpProspero documents loudness in LKFS) and that shadPS4's NOT_INIT before `sceAudioOutInit` is not modelled. A unit test (`audio_out_system_state`) checks the result, the loudness and the null pointer. ### Tested **Windows 11 (10.0.26200), MinGW build, on current `main` (`a6dcea927`) + this commit (`abd3af907`)** - **Unit test:** `ctest -R audio_out_system_state` passes. - **Conventions:** `python3 tools/check_conventions.py --base origin/main` passes. - **PPSA30528:** executable converted again with this branch's relinker, libs from this branch only, no local workarounds: the title loads past the import and reaches gameplay (Blackwater, screenshot attached). Not tested: Linux/macOS. ### 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] Unblocks: PPSA30528 (Red Dead Redemption): it does not load without this export - [x] GPUs tested: n/a - [x] AI-assisted: yes
bcortezf commented 2026-10-14 20:11:08 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by bcortezf on 2026-10-14T20:11:08Z.


could someone check this? @adriadam10

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6177372715 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5965#issuecomment-6177372715). Originally posted by [bcortezf](https://github.com/bcortezf) on 2026-10-14T20:11:08Z. --- could someone check this? @adriadam10
adriadam10 commented 2026-10-16 19:08:09 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-16T19:08:09Z.

Review: CHANGES_REQUESTED


Thanks. Build and the AudioOut ctest scope are green here, and audio_out_system_state fails to build without the change. One thing to fix:

  • core/libs/SceTypes.hpp:575 AudioOutSystemState is 64 bytes (copied from AudioOut2SystemState), but the sources the debt line cites say 32: shadPS4's OrbisAudioOutSystemState is float loudness; u8 reserved8[4]; u64 reserved64[3], and SharpProspero's SceAudioOutSystemState has Size = 32. Please use the 32-byte layout (std::uint64_t reserved[3]), and add a static_assert(sizeof(...) == 32).
  • docs/dev/debt/libSceAudioOut.md:15: the layout is not from shadPS4/fpPS4 as written, so correct it once the struct matches. Also note there that shadPS4 returns NOT_INIT before init (not modelled) and that SharpProspero documents loudness in LKFS, so the constant 0.0f is unconfirmed.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5552494901 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5965#pullrequestreview-5552494901). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-16T19:08:09Z. **Review:** CHANGES_REQUESTED --- Thanks. Build and the AudioOut ctest scope are green here, and `audio_out_system_state` fails to build without the change. One thing to fix: - `core/libs/SceTypes.hpp:575` `AudioOutSystemState` is 64 bytes (copied from `AudioOut2SystemState`), but the sources the debt line cites say 32: shadPS4's `OrbisAudioOutSystemState` is `float loudness; u8 reserved8[4]; u64 reserved64[3]`, and SharpProspero's `SceAudioOutSystemState` has `Size = 32`. Please use the 32-byte layout (`std::uint64_t reserved[3]`), and add a `static_assert(sizeof(...) == 32)`. - `docs/dev/debt/libSceAudioOut.md:15`: the layout is not from shadPS4/fpPS4 as written, so correct it once the struct matches. Also note there that shadPS4 returns NOT_INIT before init (not modelled) and that SharpProspero documents loudness in LKFS, so the constant `0.0f` is unconfirmed.
xXPBSXx commented 2026-10-21 02:43:30 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-21T02:43:30Z.


@bcortezf this PR now conflicts with main in docs/dev/debt/libSceAudioOut.md (the sceAudioOutSysOpen entry was rewritten there).

In case it helps: I rebased your commit onto current main (cd700fe9ec) without changing it, keeping you as its author, and resolved only that debt conflict (your sceAudioOutGetSystemState entry stays, the main text of the sceAudioOutSys* entry stays): branch xXPBSXx:carry/5965-audioout-system-state, head 4bff38aa2d. You can take it with git fetch https://github.com/xXPBSXx/AnyPS5 carry/5965-audioout-system-state and git reset --hard FETCH_HEAD, or rebase yourself; I will not open a second PR for it.

Windows 10 19045, WinLibs GCC 15.2.0 r7, Release, BUILD_TESTING=ON, on that head:

  • ctest -R '^audio_out_system_state$' passes 3 of 3; the 38 audio_out* tests pass (38 of 38).
  • With core/libs/SceTypes.hpp and libSceAudioOut/src/AudioOut.cpp restored to main (your new test kept), audio_out_system_state_tests does not compile ('AudioOutSystemState' was not declared).
  • python tools/check_conventions.py --base upstream/main passes.
    Not tested: Linux/macOS, a title run (PPSA30528).

AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6306700274 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5965#issuecomment-6306700274). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-21T02:43:30Z. --- @bcortezf this PR now conflicts with `main` in `docs/dev/debt/libSceAudioOut.md` (the `sceAudioOutSysOpen` entry was rewritten there). In case it helps: I rebased your commit onto current `main` (`cd700fe9ec`) without changing it, keeping you as its author, and resolved only that debt conflict (your `sceAudioOutGetSystemState` entry stays, the `main` text of the `sceAudioOutSys*` entry stays): branch `xXPBSXx:carry/5965-audioout-system-state`, head `4bff38aa2d`. You can take it with `git fetch https://github.com/xXPBSXx/AnyPS5 carry/5965-audioout-system-state` and `git reset --hard FETCH_HEAD`, or rebase yourself; I will not open a second PR for it. Windows 10 19045, WinLibs GCC 15.2.0 r7, Release, `BUILD_TESTING=ON`, on that head: - `ctest -R '^audio_out_system_state$'` passes 3 of 3; the 38 `audio_out*` tests pass (38 of 38). - With `core/libs/SceTypes.hpp` and `libSceAudioOut/src/AudioOut.cpp` restored to `main` (your new test kept), `audio_out_system_state_tests` does not compile (`'AudioOutSystemState' was not declared`). - `python tools/check_conventions.py --base upstream/main` passes. Not tested: Linux/macOS, a title run (PPSA30528). AI-assisted (Claude Code).
bcortezf commented 2026-10-21 23:36:50 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by bcortezf on 2026-10-21T23:36:50Z.


@adriadam10 Done. struct is now 32 bytes with a static_assert, debt entry corrected (sources, LKFS, NOT_INIT not modelled), rebased on current main.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6328973535 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5965#issuecomment-6328973535). Originally posted by [bcortezf](https://github.com/bcortezf) on 2026-10-21T23:36:50Z. --- @adriadam10 Done. struct is now 32 bytes with a static_assert, debt entry corrected (sources, LKFS, NOT_INIT not modelled), rebased on current main.
bcortezf commented 2026-10-22 00:27:08 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by bcortezf on 2026-10-22T00:27:08Z.


btw, with this, im able to run rdr1 at 17 fps

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6329653387 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5965#issuecomment-6329653387). Originally posted by [bcortezf](https://github.com/bcortezf) on 2026-10-22T00:27:08Z. --- btw, with this, im able to run rdr1 at 17 fps
krishalivaibhav commented 2026-10-22 12:58:55 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by krishalivaibhav on 2026-10-22T12:58:55Z.


Re-checked head abd3af907: AudioOutSystemState is now 32 bytes, with the static_assert, so adriadam10's size point looks resolved. The null path returns 0x80260004, as described. Small nit: only loudness is written, so the reserved fields keep the caller's bytes; *state = {} before setting loudness would match the other AudioOut getters. Not blocking. (Code review only; I don't have PPSA30528 to test.)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6341343767 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5965#issuecomment-6341343767). Originally posted by [krishalivaibhav](https://github.com/krishalivaibhav) on 2026-10-22T12:58:55Z. --- Re-checked head abd3af907: `AudioOutSystemState` is now 32 bytes, with the static_assert, so adriadam10's size point looks resolved. The null path returns 0x80260004, as described. Small nit: only `loudness` is written, so the reserved fields keep the caller's bytes; `*state = {}` before setting loudness would match the other AudioOut getters. Not blocking. (Code review only; I don't have PPSA30528 to test.)
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!5965
No description provided.