feat(libSceAudio3d): mix the bed and deliver audio through AudioOut #6148

Merged
011010 merged 18 commits from upstream-pr/6148 into main 2026-10-20 20:53:16 +00:00
011010 commented 2026-10-14 23:31:51 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by 011010 on 2026-10-14T23:31:51Z.


What

The bed path of libSceAudio3d, on its own and on current main:

  • sceAudio3dBedWrite and sceAudio3dBedWrite2 store the bed, sceAudio3dPortAdvance mixes it into a stereo frame with a linear-balance pan and a 5.1/7.1 downmix (Mixer.hpp) and queues the frame, and sceAudio3dPortPush opens a type-126 AudioOut port on first use and submits the queued frames to it.
  • The explicit sceAudio3dAudioOutOpen, sceAudio3dAudioOutOutput and sceAudio3dAudioOutOutputs exports queue their blocks, and sceAudio3dPortPush and sceAudio3dPortFlush drain them.

The stubs are not here. The seventeen NotImplemented exports this branch carried are gone; they are a separate change, as you asked. The diff is six files, 529 insertions, down from 687 lines with the stubs.

Two bugs fixed on the way. The branch had invented AUDIO3D_ERROR_NOT_SUPPORTED as 0x80EA0005, which shadPS4's error enum names OUT_OF_MEMORY; the unsupported buffer mode is 0x80EA0008, which shadPS4 uses and which prosper reads from the PS5 module's own error table. The constant now follows them. Separately, guest_audio3d_mixer links libc and loads libc.prx, so on Windows it exited 0xC0000135 (DLL not found) until it prepended the unpatched library directory to PATH, the way every other test that links libc does; that is the second commit of this head.

The unverified choices now name their reference, one entry each under "Unknown function info" in the technical-debt file: the downmix coefficients and the dropped LFE follow shadPS4 (fpPS4 agrees on the LFE) against prosper's contradiction, the channel order follows shadPS4, prosper and fpPS4, the return of sceAudio3dAudioOutOutput follows KytyPS5 and prosper against shadPS4's total-sample answer, and the full-queue NOT_READY follows shadPS4, the only reference with a body. Where a reference has no body, that is said instead of guessed.

The blocking push runs at real time, and there is a test that measures it: guest_audio3d_port pushes 200 frames of 256 samples at 48 kHz and requires the elapsed time to be the duration of the audio, the shape libSceAudioOut's own real-time test uses.

Tested

Linux (Ubuntu 24.04.5, x86-64, GCC 13.3.0, CMake 3.28.3, Ninja 1.11.1), on this branch rebased onto current main (d5bd6304c):

  • ctest --test-dir build -R "guest_audio3d" → 3/3 passed (guest_audio3d_parameters, guest_audio3d_port, guest_audio3d_mixer).
  • The whole audio suite → 48/48 passed.
  • The real-time measurement: 200 frames of 256 samples at 48 kHz are 1.0666 s of audio. The author's run measured 1.0225 s, the 44 ms being the AudioOut's 40 ms TARGET_LATENCY_US, the audio the queue holds ahead of real time; on the rebased head the test passed in 1.29 s of wall clock.
  • The full suite → 1659 tests, 18 failures, all of them *Skipped write-watch tests that need UFFD_FEATURE_WP_ASYNC, which the 6.6 kernel of this container lacks (CI's Linux runner has 6.13+).
  • python3 tools/check_conventions.py --base origin/main → all conventions checks passed.

Windows (Windows 11 26200, NVIDIA GeForce RTX 3050, driver 617.14, winlibs GCC 15.2.0, CMake 4.3.1, Ninja 1.13.2), on the same head:

  • ctest --test-dir build -R "audio" → 44/44 passed.
  • guest_audio3d_port passed in 1.42 s. The test requires the 1.0666 s of audio to be paced by the device and accepts 0.917–1.367 s, so a passing run is a run whose pacing comes from the AudioOut queue, not from a wait in the caller.
  • The full suite → 1701 tests, 2 failures, both agc_driver_* write-watch/DCC tests that this GPU cannot run and that the windows job treats as skips (tools/check_skips.py accepts any agc* skip there). No audio test fails.

Not tested on macOS, and not tested on a PS5 title. guest_audio3d_port is the check to run on any other host.

The title evidence is still missing. I could not produce it, and I am not going to pretend otherwise: the log that shows FIFA 21 calling sceAudio3dBedWrite, sceAudio3dBedWrite2 or sceAudio3dPortPush does not exist yet, and neither does a log that shows it stopping on one of the stubs this branch used to carry. I have asked for it in this thread with the exact steps, because the relinker's --trace-imports records the calls the title makes to the libraries named in APS5_TRACE_CALLS and prints them with their NIDs.

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: #6044
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4865961384 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6148). Originally posted by [011010](https://github.com/011010) on 2026-10-14T23:31:51Z. --- ### What The bed path of `libSceAudio3d`, on its own and on current `main`: - `sceAudio3dBedWrite` and `sceAudio3dBedWrite2` store the bed, `sceAudio3dPortAdvance` mixes it into a stereo frame with a linear-balance pan and a 5.1/7.1 downmix ([Mixer.hpp](../../../core/libs/prx/libSceAudio3d/Mixer.hpp)) and queues the frame, and `sceAudio3dPortPush` opens a type-126 AudioOut port on first use and submits the queued frames to it. - The explicit `sceAudio3dAudioOutOpen`, `sceAudio3dAudioOutOutput` and `sceAudio3dAudioOutOutputs` exports queue their blocks, and `sceAudio3dPortPush` and `sceAudio3dPortFlush` drain them. **The stubs are not here.** The seventeen `NotImplemented` exports this branch carried are gone; they are a separate change, as you asked. The diff is six files, 529 insertions, down from 687 lines with the stubs. **Two bugs fixed on the way.** The branch had invented `AUDIO3D_ERROR_NOT_SUPPORTED` as `0x80EA0005`, which [shadPS4's error enum](https://github.com/shadps4-emu/shadPS4/blob/main/src/core/libraries/audio3d/audio3d_error.h) names `OUT_OF_MEMORY`; the unsupported buffer mode is `0x80EA0008`, which shadPS4 uses and which [prosper](https://github.com/mattias800/prosper) reads from the PS5 module's own error table. The constant now follows them. Separately, `guest_audio3d_mixer` links `libc` and loads `libc.prx`, so on Windows it exited `0xC0000135` (DLL not found) until it prepended the unpatched library directory to `PATH`, the way every other test that links `libc` does; that is the second commit of this head. **The unverified choices now name their reference**, one entry each under "Unknown function info" in the technical-debt file: the downmix coefficients and the dropped LFE follow shadPS4 (fpPS4 agrees on the LFE) against prosper's contradiction, the channel order follows shadPS4, prosper and fpPS4, the return of `sceAudio3dAudioOutOutput` follows KytyPS5 and prosper against shadPS4's total-sample answer, and the full-queue `NOT_READY` follows shadPS4, the only reference with a body. Where a reference has no body, that is said instead of guessed. **The blocking push runs at real time**, and there is a test that measures it: `guest_audio3d_port` pushes 200 frames of 256 samples at 48 kHz and requires the elapsed time to be the duration of the audio, the shape `libSceAudioOut`'s own real-time test uses. ### Tested **Linux** (Ubuntu 24.04.5, x86-64, GCC 13.3.0, CMake 3.28.3, Ninja 1.11.1), on this branch rebased onto current `main` (`d5bd6304c`): - `ctest --test-dir build -R "guest_audio3d"` → **3/3 passed** (`guest_audio3d_parameters`, `guest_audio3d_port`, `guest_audio3d_mixer`). - The whole audio suite → **48/48 passed**. - The real-time measurement: 200 frames of 256 samples at 48 kHz are 1.0666 s of audio. The author's run measured **1.0225 s**, the 44 ms being the AudioOut's 40 ms `TARGET_LATENCY_US`, the audio the queue holds ahead of real time; on the rebased head the test passed in **1.29 s** of wall clock. - The full suite → 1659 tests, 18 failures, all of them `*Skipped` write-watch tests that need `UFFD_FEATURE_WP_ASYNC`, which the 6.6 kernel of this container lacks (CI's Linux runner has 6.13+). - `python3 tools/check_conventions.py --base origin/main` → all conventions checks passed. **Windows** (Windows 11 26200, NVIDIA GeForce RTX 3050, driver 617.14, winlibs GCC 15.2.0, CMake 4.3.1, Ninja 1.13.2), on the same head: - `ctest --test-dir build -R "audio"` → **44/44 passed**. - `guest_audio3d_port` passed in **1.42 s**. The test requires the 1.0666 s of audio to be paced by the device and accepts 0.917–1.367 s, so a passing run is a run whose pacing comes from the AudioOut queue, not from a wait in the caller. - The full suite → 1701 tests, 2 failures, both `agc_driver_*` write-watch/DCC tests that this GPU cannot run and that the `windows` job treats as skips (`tools/check_skips.py` accepts any `agc*` skip there). No audio test fails. **Not tested on macOS**, and not tested on a PS5 title. `guest_audio3d_port` is the check to run on any other host. **The title evidence is still missing.** I could not produce it, and I am not going to pretend otherwise: the log that shows FIFA 21 calling `sceAudio3dBedWrite`, `sceAudio3dBedWrite2` or `sceAudio3dPortPush` does not exist yet, and neither does a log that shows it stopping on one of the stubs this branch used to carry. I have asked for it in this thread with the exact steps, because the relinker's `--trace-imports` records the calls the title makes to the libraries named in `APS5_TRACE_CALLS` and prints them with their NIDs. ### 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: #6044 - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
github-actions[bot] commented 2026-10-14 23:32:23 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-14T23:32:23Z.


Progress report (aa1b1bf → 7caa8fa)

📈 System libraries: 64.5% (+0.04%, +6 implemented functions)

✅ 6 implemented
Library Name
libSceAudio3d sceAudio3dAudioOutClose
libSceAudio3d sceAudio3dAudioOutOpen
libSceAudio3d sceAudio3dAudioOutOutput
libSceAudio3d sceAudio3dAudioOutOutputs
libSceAudio3d sceAudio3dBedWrite
libSceAudio3d sceAudio3dBedWrite2
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6180804936 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6148#issuecomment-6180804936). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-14T23:32:23Z. --- <!-- progress-report --> ### Progress report (aa1b1bf → 7caa8fa) 📈 **System libraries**: 64.5% (+0.04%, +6 implemented functions) <details> <summary>✅ 6 implemented</summary> | Library | Name | | - | - | | libSceAudio3d | `sceAudio3dAudioOutClose` | | libSceAudio3d | `sceAudio3dAudioOutOpen` | | libSceAudio3d | `sceAudio3dAudioOutOutput` | | libSceAudio3d | `sceAudio3dAudioOutOutputs` | | libSceAudio3d | `sceAudio3dBedWrite` | | libSceAudio3d | `sceAudio3dBedWrite2` | </details>
011010 commented 2026-10-14 23:40:54 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by 011010 on 2026-10-14T23:40:54Z.


Rebased on current main (2559e9623) and re-verified on Linux (Ubuntu 24.04, x86-64) against this head:

  • cmake configure and ninja both return 0, and the test binaries are freshly linked for this head rather than reused artefacts (the mixer test binary's timestamp moves past the edit of Export.cpp).
  • ctest -R audio → 23/23 passed, including guest_audio3d_parameters, guest_audio3d_port, guest_audio3d_mixer and the whole audio_out* set.

Object PCM/GAIN/POSITION still produce no audio (the PS5 object-attribute ABI is unknown and recorded in TechnicalDebt); what the title reaches first is the relink above.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6180918368 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6148#issuecomment-6180918368). Originally posted by [011010](https://github.com/011010) on 2026-10-14T23:40:54Z. --- Rebased on current `main` (`2559e9623`) and re-verified on Linux (Ubuntu 24.04, x86-64) against this head: - `cmake` configure and `ninja` both return 0, and the test binaries are freshly linked for this head rather than reused artefacts (the mixer test binary's timestamp moves past the edit of `Export.cpp`). - `ctest -R audio` → **23/23 passed**, including `guest_audio3d_parameters`, `guest_audio3d_port`, `guest_audio3d_mixer` and the whole `audio_out*` set. Object PCM/GAIN/POSITION still produce no audio (the PS5 object-attribute ABI is unknown and recorded in TechnicalDebt); what the title reaches first is the relink above.
011010 commented 2026-10-15 00:02:15 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by 011010 on 2026-10-15T00:02:15Z.


The overlap bot is right: #5968 (@MarcZX100) implements sceAudio3dPortGetAttributesSupported and touches the same two files (Export.cpp, tests/GuestAudio3dPort.cpp).

His change is the smaller one and it unblocks the title by itself, so this PR should follow his rather than compete with it:

  • I am rebasing this on #5968 and dropping my copy of sceAudio3dPortGetAttributesSupported in favour of his.
  • This PR will then carry Depends on: #5968.
  • The rest of the surface here (the bed path, the mixer, the AudioOut delivery) is what the title needs once it gets past the relink, so it stays.

I will push the rebased head once #5968 lands.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6181193856 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6148#issuecomment-6181193856). Originally posted by [011010](https://github.com/011010) on 2026-10-15T00:02:15Z. --- The overlap bot is right: #5968 (@MarcZX100) implements `sceAudio3dPortGetAttributesSupported` and touches the same two files (`Export.cpp`, `tests/GuestAudio3dPort.cpp`). His change is the smaller one and it unblocks the title by itself, so this PR should follow his rather than compete with it: - I am rebasing this on #5968 and dropping my copy of `sceAudio3dPortGetAttributesSupported` in favour of his. - This PR will then carry `Depends on: #5968`. - The rest of the surface here (the bed path, the mixer, the AudioOut delivery) is what the title needs once it gets past the relink, so it stays. I will push the rebased head once #5968 lands.
011010 commented 2026-10-15 14:59:33 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by 011010 on 2026-10-15T14:59:33Z.


Done: the head is now rebased on #5968 (Depends on: #5968) and no longer carries its own sceAudio3dPortGetAttributesSupported or the tests for it, so the two PRs no longer conflict in Export.cpp or GuestAudio3dPort.cpp.

Re-verified at this head: ctest -R audio → 23/23 passed.

While #5968 is open this branch is stacked on it, so the diff above also shows that one commit; it will drop out once #5968 lands and I rebase on main.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6195157918 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6148#issuecomment-6195157918). Originally posted by [011010](https://github.com/011010) on 2026-10-15T14:59:33Z. --- Done: the head is now rebased on #5968 (`Depends on: #5968`) and no longer carries its own `sceAudio3dPortGetAttributesSupported` or the tests for it, so the two PRs no longer conflict in `Export.cpp` or `GuestAudio3dPort.cpp`. Re-verified at this head: `ctest -R audio` → **23/23 passed**. While #5968 is open this branch is stacked on it, so the diff above also shows that one commit; it will drop out once #5968 lands and I rebase on `main`.
adriadam10 commented 2026-10-18 16:38:31 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-18T16:38:31Z.

Review: CHANGES_REQUESTED


Thanks for rebasing on #5968. #5968 is merged, and it was the only thing the log in the description shows FIFA 21 stopping on, so the title now gets past the relink. Nothing here shows it reaches the bed or the push path. Before this can go in:

  • Title evidence. #5259 was closed because no title was known to need this. Please post a log from current main (with #5968) showing FIFA 21 PPSA01327 calling sceAudio3dBedWrite/BedWrite2/PortPush (or stopping on one of the stubs added here). If it stops on a different import, this PR is not what it needs.
  • Conflict with main. core/libs/prx/libSceAudio3d/Export.cpp conflicts: #5968 landed as a different commit, and b2cde4a0f changed sceAudio3dPortPush to wait with PreciseSleepUntil (Windows sleep_until wakes on a 15.6 ms step). This PR deletes that wait and relies on the blocking sceAudioOutOutput instead. Please rebase and show on Windows that a blocking sceAudio3dPortPush still runs at real time.
  • Sources for the unverified choices. Add them to docs/dev/debt/libSceAudio3d.md under "Unknown function info", one line each: the downmix coefficients (0.7071, LFE dropped, Mixer.hpp:21-57), the channel order, the granularity return value of sceAudio3dAudioOutOutput (Export.cpp:429), NOT_SUPPORTED for buffer modes other than 2 and NOT_READY on a full queue in sceAudio3dPortAdvance (Export.cpp:153-154; main throws on a full queue). Say which reference each follows (shadPS4, KytyPS5, prosper); where none has a body, throw instead of guessing.
  • Scope. 687 lines in one PR: the mixer, the AudioOut bridge and about 15 NotImplemented stubs. Please split the stubs (they add nothing the title needs) from the bed path.

Welcome back once the title log is in.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5563900198 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6148#pullrequestreview-5563900198). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-18T16:38:31Z. **Review:** CHANGES_REQUESTED --- Thanks for rebasing on #5968. #5968 is merged, and it was the only thing the log in the description shows FIFA 21 stopping on, so the title now gets past the relink. Nothing here shows it reaches the bed or the push path. Before this can go in: - **Title evidence.** #5259 was closed because no title was known to need this. Please post a log from current `main` (with #5968) showing FIFA 21 `PPSA01327` calling `sceAudio3dBedWrite`/`BedWrite2`/`PortPush` (or stopping on one of the stubs added here). If it stops on a different import, this PR is not what it needs. - **Conflict with `main`.** `core/libs/prx/libSceAudio3d/Export.cpp` conflicts: #5968 landed as a different commit, and `b2cde4a0f` changed `sceAudio3dPortPush` to wait with `PreciseSleepUntil` (Windows `sleep_until` wakes on a 15.6 ms step). This PR deletes that wait and relies on the blocking `sceAudioOutOutput` instead. Please rebase and show on Windows that a blocking `sceAudio3dPortPush` still runs at real time. - **Sources for the unverified choices.** Add them to `docs/dev/debt/libSceAudio3d.md` under "Unknown function info", one line each: the downmix coefficients (`0.7071`, LFE dropped, `Mixer.hpp:21-57`), the channel order, the `granularity` return value of `sceAudio3dAudioOutOutput` (`Export.cpp:429`), `NOT_SUPPORTED` for buffer modes other than 2 and `NOT_READY` on a full queue in `sceAudio3dPortAdvance` (`Export.cpp:153-154`; `main` throws on a full queue). Say which reference each follows (shadPS4, KytyPS5, prosper); where none has a body, throw instead of guessing. - **Scope.** 687 lines in one PR: the mixer, the AudioOut bridge and about 15 `NotImplemented` stubs. Please split the stubs (they add nothing the title needs) from the bed path. Welcome back once the title log is in.
011010 commented 2026-10-19 22:33:42 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by 011010 on 2026-10-19T22:33:42Z.


Rebased onto current main and re-scoped to the bed path alone. Answering your four points one by one.

1. Scope. The seventeen NotImplemented stubs are out of this pull request; they are a separate change, as you asked. The diff is 505 lines, down from 687, and it now adds six exports: sceAudio3dBedWrite, sceAudio3dBedWrite2, sceAudio3dAudioOutOpen, sceAudio3dAudioOutOutput, sceAudio3dAudioOutOutputs and sceAudio3dAudioOutClose. The mixer (Mixer.hpp), the bed write, the mix on advance and the AudioOut bridge stay.

2. Sources for the unverified choices. They are in docs/dev/debt/libSceAudio3d.md under "Unknown function info", one entry each, and I went through the references to write them:

  • The downmix coefficients and the dropped LFE follow shadPS4 (PS4), whose DOWNMIX_CENTER and DOWNMIX_SURROUND are 0.7071 and whose DOWNMIX_LFE is 0, so its if constexpr that adds the LFE is compiled out. prosper disagrees on the LFE only, folding it into both sides with a 0.5 gain, and that is its AudioOut2 main bed path rather than an Audio3d path, so the disagreement is recorded. KytyPS5 has no Audio3d mixing at all.
  • The channel order follows shadPS4, prosper and fpPS4, which agree on L, R, C, LFE, Ls, Rs, Lrs, Rrs.
  • The return of sceAudio3dAudioOutOutput follows KytyPS5 and prosper, whose sceAudioOutOutput returns the grain, and this project's own sceAudioOutOutput, which returns the port's samplesNum. shadPS4 returns the total samples and fpPS4 returns 0; no console measurement settles it, so the difference is recorded rather than hidden.
  • NOT_READY on a full queue follows shadPS4, the only reference with a body.

This uncovered a bug. The branch had invented AUDIO3D_ERROR_NOT_SUPPORTED as 0x80EA0005, which shadPS4's error enum names OUT_OF_MEMORY; the unsupported buffer mode is 0x80EA0008, which shadPS4 uses and which prosper reads from the PS5 module's own error table. The constant is fixed and the debt entry says so.

3. The blocking push at real time. The push no longer paces locally: it hands the mixed frames to an AudioOut port and the pacing is that port's. sceAudioOutOutput blocks while the queue is over its target and waits with PreciseSleepUs, the high-resolution timer b2cde4a0f added, so on Windows this branch inherits that fix instead of duplicating it or going back to the 15.6 ms step.

There is now a test that measures it, modelled on libSceAudioOut's own real-time test: guest_audio3d_port pushes 200 frames of 256 samples at 48 kHz and requires the elapsed time to be the duration of the audio. On Linux the pushes took 1.0225 s against 1.0666 s of audio, the 44 ms being the AudioOut's 40 ms TARGET_LATENCY_US, the audio the queue holds ahead of real time. That test is also the check to run on Windows: I have no Windows host here, so I cannot give you that run, and I would rather say so than present the Linux number as if it were one.

4. The title evidence. I could not produce it, and this is the one point I have not answered. I went looking for the log in the repository and in this thread and there is none: the only trace of FIFA 21 is #5954, and the NID it stopped on, 9ZA23Ia46Po, is sceAudio3dPortGetAttributesSupported, which #5968 already provided.

I have asked for the log in a separate comment here with the exact steps, because the relinker's --trace-imports records the calls the title makes to the libraries named in APS5_TRACE_CALLS and prints them with their NIDs, so one run of the title with APS5_TRACE_CALLS=libSceAudio3d settles which of these exports FIFA 21 uses. Until that log exists I cannot claim the bed path is what the title needs, and I am not going to assert it.

Depends on: #6044, which moves the library tests to tests/media/ and changes their registration, so this pull request will need a rebase on it.

The whole audio suite passes on Linux: 48/48, and 3/3 for the guest_audio3d_* tests.

AI-assisted: yes. The builds, the test runs and the measurements above are mine.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6278845445 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6148#issuecomment-6278845445). Originally posted by [011010](https://github.com/011010) on 2026-10-19T22:33:42Z. --- Rebased onto current `main` and re-scoped to the bed path alone. Answering your four points one by one. **1. Scope.** The seventeen `NotImplemented` stubs are out of this pull request; they are a separate change, as you asked. The diff is 505 lines, down from 687, and it now adds six exports: `sceAudio3dBedWrite`, `sceAudio3dBedWrite2`, `sceAudio3dAudioOutOpen`, `sceAudio3dAudioOutOutput`, `sceAudio3dAudioOutOutputs` and `sceAudio3dAudioOutClose`. The mixer ([Mixer.hpp](../../../core/libs/prx/libSceAudio3d/Mixer.hpp)), the bed write, the mix on advance and the AudioOut bridge stay. **2. Sources for the unverified choices.** They are in `docs/dev/debt/libSceAudio3d.md` under "Unknown function info", one entry each, and I went through the references to write them: - The downmix coefficients and the dropped LFE follow [shadPS4](https://github.com/shadps4-emu/shadPS4) (PS4), whose `DOWNMIX_CENTER` and `DOWNMIX_SURROUND` are 0.7071 and whose `DOWNMIX_LFE` is 0, so its `if constexpr` that adds the LFE is compiled out. [prosper](https://github.com/mattias800/prosper) disagrees on the LFE only, folding it into both sides with a 0.5 gain, and that is its AudioOut2 main bed path rather than an Audio3d path, so the disagreement is recorded. KytyPS5 has no Audio3d mixing at all. - The channel order follows shadPS4, prosper and fpPS4, which agree on L, R, C, LFE, Ls, Rs, Lrs, Rrs. - The return of `sceAudio3dAudioOutOutput` follows KytyPS5 and prosper, whose `sceAudioOutOutput` returns the grain, and this project's own `sceAudioOutOutput`, which returns the port's `samplesNum`. shadPS4 returns the total samples and fpPS4 returns 0; no console measurement settles it, so the difference is recorded rather than hidden. - `NOT_READY` on a full queue follows shadPS4, the only reference with a body. **This uncovered a bug.** The branch had invented `AUDIO3D_ERROR_NOT_SUPPORTED` as `0x80EA0005`, which shadPS4's error enum names `OUT_OF_MEMORY`; the unsupported buffer mode is `0x80EA0008`, which shadPS4 uses and which prosper reads from the PS5 module's own error table. The constant is fixed and the debt entry says so. **3. The blocking push at real time.** The push no longer paces locally: it hands the mixed frames to an AudioOut port and the pacing is that port's. `sceAudioOutOutput` blocks while the queue is over its target and waits with `PreciseSleepUs`, the high-resolution timer b2cde4a0f added, so on Windows this branch inherits that fix instead of duplicating it or going back to the 15.6 ms step. There is now a test that measures it, modelled on `libSceAudioOut`'s own real-time test: `guest_audio3d_port` pushes 200 frames of 256 samples at 48 kHz and requires the elapsed time to be the duration of the audio. On Linux the pushes took **1.0225 s** against 1.0666 s of audio, the 44 ms being the AudioOut's 40 ms `TARGET_LATENCY_US`, the audio the queue holds ahead of real time. That test is also the check to run on Windows: I have no Windows host here, so I cannot give you that run, and I would rather say so than present the Linux number as if it were one. **4. The title evidence.** I could not produce it, and this is the one point I have not answered. I went looking for the log in the repository and in this thread and there is none: the only trace of FIFA 21 is #5954, and the NID it stopped on, `9ZA23Ia46Po`, is `sceAudio3dPortGetAttributesSupported`, which #5968 already provided. I have asked for the log in a separate comment here with the exact steps, because the relinker's `--trace-imports` records the calls the title makes to the libraries named in `APS5_TRACE_CALLS` and prints them with their NIDs, so one run of the title with `APS5_TRACE_CALLS=libSceAudio3d` settles which of these exports FIFA 21 uses. Until that log exists I cannot claim the bed path is what the title needs, and I am not going to assert it. `Depends on: #6044`, which moves the library tests to `tests/media/` and changes their registration, so this pull request will need a rebase on it. The whole audio suite passes on Linux: 48/48, and 3/3 for the `guest_audio3d_*` tests. AI-assisted: yes. The builds, the test runs and the measurements above are mine.
011010 commented 2026-10-19 22:33:44 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by 011010 on 2026-10-19T22:33:44Z.


@DanteOfficial, this pull request needs one thing that only someone with FIFA 21 can produce, and your #5954 is the thread that got the title past its first blocker.

What is missing. A log that shows which libSceAudio3d exports the title actually calls, so that we can tell whether the bed path this pull request carries (sceAudio3dBedWrite, sceAudio3dBedWrite2 and the new sceAudio3dPortPush) is what FIFA 21 needs, or whether it goes through objects and the port API only. Without it the reviewer cannot judge the change, and neither can I.

How to get it. The relinker can record the calls the title makes to a library and print them with their NIDs:

  1. Convert the executable with --trace-imports (Windows only, it conflicts with --lazy-binding).
  2. Run it with APS5_TRACE_CALLS=libSceAudio3d in the environment.
  3. The crash or abort report then ends with the last traced calls and the most called traced imports, each with the library and the NID the title imports it as.

The report looks like this:

last traced system library calls (APS5_TRACE_CALLS):
  #1 thread 9384 libSceAudio3d.prx k+AXqu2-eBc from 0x0000000140010006 app.exe+0x10006
most called traced imports (1 calls in total):
             1 libSceAudio3d.prx k+AXqu2-eBc

Posting that section for libSceAudio3d is enough. If the NIDs are easier to read as names, python3 tools/nid_names.py --nid <nid> in this repository resolves any of them.

If the title runs to a menu or further on your machine, the trace is in the report of whatever stops it. If it does not stop, the title has to be made to abort for the report to be written.

Nothing here is a blocker only for this pull request: the same log would settle what libSceAudio3d needs for any title, and the same --trace-imports run would show the other libraries the title leans on.

Thank you.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6278845772 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6148#issuecomment-6278845772). Originally posted by [011010](https://github.com/011010) on 2026-10-19T22:33:44Z. --- @DanteOfficial, this pull request needs one thing that only someone with FIFA 21 can produce, and your #5954 is the thread that got the title past its first blocker. **What is missing.** A log that shows which `libSceAudio3d` exports the title actually calls, so that we can tell whether the bed path this pull request carries (`sceAudio3dBedWrite`, `sceAudio3dBedWrite2` and the new `sceAudio3dPortPush`) is what FIFA 21 needs, or whether it goes through objects and the port API only. Without it the reviewer cannot judge the change, and neither can I. **How to get it.** The relinker can record the calls the title makes to a library and print them with their NIDs: 1. Convert the executable with `--trace-imports` (Windows only, it conflicts with `--lazy-binding`). 2. Run it with `APS5_TRACE_CALLS=libSceAudio3d` in the environment. 3. The crash or abort report then ends with the last traced calls and the most called traced imports, each with the library and the NID the title imports it as. The report looks like this: ``` last traced system library calls (APS5_TRACE_CALLS): #1 thread 9384 libSceAudio3d.prx k+AXqu2-eBc from 0x0000000140010006 app.exe+0x10006 most called traced imports (1 calls in total): 1 libSceAudio3d.prx k+AXqu2-eBc ``` Posting that section for `libSceAudio3d` is enough. If the NIDs are easier to read as names, `python3 tools/nid_names.py --nid <nid>` in this repository resolves any of them. If the title runs to a menu or further on your machine, the trace is in the report of whatever stops it. If it does not stop, the title has to be made to abort for the report to be written. Nothing here is a blocker only for this pull request: the same log would settle what `libSceAudio3d` needs for any title, and the same `--trace-imports` run would show the other libraries the title leans on. Thank you.
011010 commented 2026-10-20 02:36:39 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by 011010 on 2026-10-20T02:36:39Z.


Rebased onto main again (d5bd6304c, 16 commits, no conflicts) and ran the head on Windows too, because a pull request never gets the linux or windows job: in build.yml both run only on a push to main or a manual dispatch, so this thread has only ever seen conventions, labels, report and the path-gated jobs. These are the runs the review asked for.

Windows 11 26200, GeForce RTX 3050 (driver 617.14), winlibs GCC 15.2.0, CMake 4.3.1

  • ctest -R "audio" → 44/44 passed.
  • guest_audio3d_port passed in 1.42 s. That is the real-time check: 200 frames of 256 samples at 48 kHz are 1.0666 s of audio, and the assertion accepts 0.917–1.367 s, so a passing run is one paced by the AudioOut queue rather than by a wait in the caller.
  • Full suite: 1701 tests, 2 failures, both agc_driver_* write-watch/DCC tests that this GPU cannot run and that tools/check_skips.py --job windows treats as skips. No audio test fails.

Linux (Ubuntu 24.04 container, GCC 13.3)

  • ctest -R "audio" → 48/48 passed; guest_audio3d_port passed in 1.29 s.
  • Full suite: 1659 tests, 18 failures, every one of them a *Skipped write-watch test that needs UFFD_FEATURE_WP_ASYNC, absent from this container's 6.6 kernel.

One bug found and fixed in this head. On Windows guest_audio3d_mixer exited 0xC0000135, DLL not found: the test links libc and loads libc.prx, but unlike every other test in the tree that links libc it did not prepend the unpatched library directory to PATH. d5bd6304c adds the same ENVIRONMENT_MODIFICATION block its two neighbouring tests use. Without it, the first push to main after the merge would have failed the windows job, which does run on a push.

The title log is still the one thing this head cannot produce, and that request stands.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6282024301 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6148#issuecomment-6282024301). Originally posted by [011010](https://github.com/011010) on 2026-10-20T02:36:39Z. --- Rebased onto `main` again (`d5bd6304c`, 16 commits, no conflicts) and ran the head on Windows too, because a pull request never gets the `linux` or `windows` job: in `build.yml` both run only on a push to `main` or a manual dispatch, so this thread has only ever seen `conventions`, `labels`, `report` and the path-gated jobs. These are the runs the review asked for. **Windows 11 26200, GeForce RTX 3050 (driver 617.14), winlibs GCC 15.2.0, CMake 4.3.1** - `ctest -R "audio"` → **44/44 passed**. - `guest_audio3d_port` passed in **1.42 s**. That is the real-time check: 200 frames of 256 samples at 48 kHz are 1.0666 s of audio, and the assertion accepts 0.917–1.367 s, so a passing run is one paced by the AudioOut queue rather than by a wait in the caller. - Full suite: 1701 tests, 2 failures, both `agc_driver_*` write-watch/DCC tests that this GPU cannot run and that `tools/check_skips.py --job windows` treats as skips. No audio test fails. **Linux (Ubuntu 24.04 container, GCC 13.3)** - `ctest -R "audio"` → **48/48 passed**; `guest_audio3d_port` passed in **1.29 s**. - Full suite: 1659 tests, 18 failures, every one of them a `*Skipped` write-watch test that needs `UFFD_FEATURE_WP_ASYNC`, absent from this container's 6.6 kernel. **One bug found and fixed in this head.** On Windows `guest_audio3d_mixer` exited `0xC0000135`, DLL not found: the test links `libc` and loads `libc.prx`, but unlike every other test in the tree that links `libc` it did not prepend the unpatched library directory to `PATH`. `d5bd6304c` adds the same `ENVIRONMENT_MODIFICATION` block its two neighbouring tests use. Without it, the first push to `main` after the merge would have failed the `windows` job, which does run on a push. The title log is still the one thing this head cannot produce, and that request stands.
github-actions[bot] commented 2026-10-20 10:23:29 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-20T10:23:29Z.


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 8331 docs/dev/debt/libSceAudio3d.md L11
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6288774276 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6148#issuecomment-6288774276). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-20T10:23:29Z. --- <!-- pr-overlap --> 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 8331](https://www.github.com/boykopovar/AnyPS5/pull/8331) | `docs/dev/debt/libSceAudio3d.md` [L11](https://github.com/boykopovar/AnyPS5/blob/cabd80f472b86b5ffa3410fc91db4b83df278d27/docs/dev/debt/libSceAudio3d.md#L11) | | |
oneandonlydean commented 2026-10-20 15:31:54 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-20T15:31:54Z.


@adriadam10 approved this head, so please treat this as one behaviour difference we noticed, not a block on that review; you and the author can weigh it.

Thanks for re-scoping this. One behaviour to fix: sceAudio3dBedWrite2 stores the bed in g_port.bed, and sceAudio3dPortAdvance mixes it without clearing it. An advance with no new bed write therefore replays the previous block instead of mixing silence, and two writes before one advance keep only the second. shadPS4, which the debt entries follow for the downmix, channel order and the full-queue NOT_READY, queues each bed write (ConvertAndEnqueue into bed_queue) and consumes it when it mixes (pop_front in ProcessMixQueue). Please consume the bed on advance (clear it after MixFrame, or queue the writes) and add a case to guest_audio3d_port: write a bed, advance twice, and check that the second frame is silent.

Optional: for buffer mode 1, shadPS4 and prosper both advance normally. Since the debt entry says no reference returns NOT_SUPPORTED there, throwing would fit CONTRIBUTING better than an error code.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6294604248 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6148#issuecomment-6294604248). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-20T15:31:54Z. --- @adriadam10 approved this head, so please treat this as one behaviour difference we noticed, not a block on that review; you and the author can weigh it. Thanks for re-scoping this. One behaviour to fix: `sceAudio3dBedWrite2` stores the bed in `g_port.bed`, and `sceAudio3dPortAdvance` mixes it without clearing it. An advance with no new bed write therefore replays the previous block instead of mixing silence, and two writes before one advance keep only the second. shadPS4, which the debt entries follow for the downmix, channel order and the full-queue `NOT_READY`, queues each bed write (`ConvertAndEnqueue` into `bed_queue`) and consumes it when it mixes (`pop_front` in `ProcessMixQueue`). Please consume the bed on advance (clear it after `MixFrame`, or queue the writes) and add a case to `guest_audio3d_port`: write a bed, advance twice, and check that the second frame is silent. Optional: for buffer mode 1, shadPS4 and prosper both advance normally. Since the debt entry says no reference returns `NOT_SUPPORTED` there, throwing would fit CONTRIBUTING better than an error code.
011010 commented 2026-10-20 19:35:44 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by 011010 on 2026-10-20T19:35:44Z.


You are right on both halves, and I could reproduce the first one straight away: sceAudio3dBedWrite2 wrote into a single g_port.bed and sceAudio3dPortAdvance mixed it without clearing, so an advance with no new write replayed the last block, and two writes before one advance kept only the second.

Fixed by queueing the writes, as shadPS4 does. The bed is a std::deque of blocks now: each sceAudio3dBedWrite2 enqueues one, the queue is bounded by queue_depth and returns NOT_READY when full (shadPS4's ConvertAndEnqueue does the same against parameters.queue_depth), and sceAudio3dPortAdvance pops one and mixes it. An advance with nothing queued mixes silence through the mixer's empty-source path.

About the test case you asked for. I added one, but not exactly in the shape you described, and I want to be straight about why: the port API has no way to read a mixed frame back. sceAudio3dPortGetQueueLevel reports levels, and the frames leave through sceAudio3dAudioOutOutput into a real AudioOut port, so write a bed, advance twice, and check the second frame is silent cannot be asserted through the exported surface. What guest_audio3d_port checks instead is the queue's behaviour, which is what the bug broke:

  • fill the bed queue to queue_depth, require the next write to be NOT_READY;
  • advance, and require the consumed bed to make room for a write again;
  • advance twice and require both frames queued;
  • flush, advance with nothing queued, and require a frame to be queued anyway.

The silence itself is already covered where it is produced: guest_audio3d_mixer asserts that MixFrame with no source writes zeros (no sources produce silence), which is the path an empty bed queue now takes.

I checked the new case against the old code: it fails at a full bed queue must be NOT_READY, so it catches the regression rather than passing on both sides. With the fix, guest_audio3d_* is 3/3 and the whole audio suite is 48/48 on Linux.

The technical-debt entry for the bed path now says the writes are queued, the bound, and that an advance with nothing queued mixes silence.

Happy to reshape the test if you would rather have an explicit frame reader to make the assertion possible; that would be a new export and I would do it as its own change.

AI-assisted: yes. The build, the test runs and the old-code check are mine.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6299631624 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6148#issuecomment-6299631624). Originally posted by [011010](https://github.com/011010) on 2026-10-20T19:35:44Z. --- You are right on both halves, and I could reproduce the first one straight away: `sceAudio3dBedWrite2` wrote into a single `g_port.bed` and `sceAudio3dPortAdvance` mixed it without clearing, so an advance with no new write replayed the last block, and two writes before one advance kept only the second. **Fixed by queueing the writes, as shadPS4 does.** The bed is a `std::deque` of blocks now: each `sceAudio3dBedWrite2` enqueues one, the queue is bounded by `queue_depth` and returns `NOT_READY` when full (shadPS4's `ConvertAndEnqueue` does the same against `parameters.queue_depth`), and `sceAudio3dPortAdvance` pops one and mixes it. An advance with nothing queued mixes silence through the mixer's empty-source path. **About the test case you asked for.** I added one, but not exactly in the shape you described, and I want to be straight about why: the port API has no way to read a mixed frame back. `sceAudio3dPortGetQueueLevel` reports levels, and the frames leave through `sceAudio3dAudioOutOutput` into a real AudioOut port, so `write a bed, advance twice, and check the second frame is silent` cannot be asserted through the exported surface. What `guest_audio3d_port` checks instead is the queue's behaviour, which is what the bug broke: - fill the bed queue to `queue_depth`, require the next write to be `NOT_READY`; - advance, and require the consumed bed to make room for a write again; - advance twice and require both frames queued; - flush, advance with nothing queued, and require a frame to be queued anyway. The silence itself is already covered where it is produced: `guest_audio3d_mixer` asserts that `MixFrame` with no source writes zeros (`no sources produce silence`), which is the path an empty bed queue now takes. I checked the new case against the old code: it fails at `a full bed queue must be NOT_READY`, so it catches the regression rather than passing on both sides. With the fix, `guest_audio3d_*` is 3/3 and the whole audio suite is 48/48 on Linux. The technical-debt entry for the bed path now says the writes are queued, the bound, and that an advance with nothing queued mixes silence. Happy to reshape the test if you would rather have an explicit frame reader to make the assertion possible; that would be a new export and I would do it as its own change. AI-assisted: yes. The build, the test runs and the old-code check are mine.
adriadam10 commented 2026-10-20 20:53:57 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-20T20:53:57Z.


Re-checked after the red Windows run on the previous head:

  • guest_audio3d_port aborted on "a blocking push must run at real time": the check also had a 300 ms wall-clock upper bound, and on a loaded runner the test took 25 s (guest_raise_exception timed out in the same run). I dropped the upper bound in a commit on your branch; the lower bound still fails without the AudioOut pacing.
  • The bed queue (BedWrite2 enqueues, bounded by queue_depth, NOT_READY when full; PortAdvance consumes one or mixes silence) fixes the replay and overwrite cases from the review, and the new CheckBedQueue pins both.

Checked the mixer, bed validation, queueing and debt entries; merged.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6301254477 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6148#issuecomment-6301254477). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-20T20:53:57Z. --- Re-checked after the red Windows run on the previous head: - `guest_audio3d_port` aborted on "a blocking push must run at real time": the check also had a 300 ms wall-clock upper bound, and on a loaded runner the test took 25 s (`guest_raise_exception` timed out in the same run). I dropped the upper bound in a commit on your branch; the lower bound still fails without the AudioOut pacing. - The bed queue (`BedWrite2` enqueues, bounded by `queue_depth`, `NOT_READY` when full; `PortAdvance` consumes one or mixes silence) fixes the replay and overwrite cases from the review, and the new `CheckBedQueue` pins both. Checked the mixer, bed validation, queueing and debt entries; merged.
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!6148
No description provided.