feat(libSceAudio3d): mix the bed and deliver audio through AudioOut #6148
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6148"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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 currentmain:sceAudio3dBedWriteandsceAudio3dBedWrite2store the bed,sceAudio3dPortAdvancemixes it into a stereo frame with a linear-balance pan and a 5.1/7.1 downmix (Mixer.hpp) and queues the frame, andsceAudio3dPortPushopens a type-126 AudioOut port on first use and submits the queued frames to it.sceAudio3dAudioOutOpen,sceAudio3dAudioOutOutputandsceAudio3dAudioOutOutputsexports queue their blocks, andsceAudio3dPortPushandsceAudio3dPortFlushdrain them.The stubs are not here. The seventeen
NotImplementedexports 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_SUPPORTEDas0x80EA0005, which shadPS4's error enum namesOUT_OF_MEMORY; the unsupported buffer mode is0x80EA0008, which shadPS4 uses and which prosper reads from the PS5 module's own error table. The constant now follows them. Separately,guest_audio3d_mixerlinkslibcand loadslibc.prx, so on Windows it exited0xC0000135(DLL not found) until it prepended the unpatched library directory toPATH, the way every other test that linkslibcdoes; 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
sceAudio3dAudioOutOutputfollows KytyPS5 and prosper against shadPS4's total-sample answer, and the full-queueNOT_READYfollows 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_portpushes 200 frames of 256 samples at 48 kHz and requires the elapsed time to be the duration of the audio, the shapelibSceAudioOut'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).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.*Skippedwrite-watch tests that needUFFD_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_portpassed 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.agc_driver_*write-watch/DCC tests that this GPU cannot run and that thewindowsjob treats as skips (tools/check_skips.pyaccepts anyagc*skip there). No audio test fails.Not tested on macOS, and not tested on a PS5 title.
guest_audio3d_portis 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,sceAudio3dBedWrite2orsceAudio3dPortPushdoes 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-importsrecords the calls the title makes to the libraries named inAPS5_TRACE_CALLSand prints them with their NIDs.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)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
sceAudio3dAudioOutClosesceAudio3dAudioOutOpensceAudio3dAudioOutOutputsceAudio3dAudioOutOutputssceAudio3dBedWritesceAudio3dBedWrite2Imported 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:cmakeconfigure andninjaboth 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 ofExport.cpp).ctest -R audio→ 23/23 passed, includingguest_audio3d_parameters,guest_audio3d_port,guest_audio3d_mixerand the wholeaudio_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.
Imported from boykopovar/AnyPS5. Originally posted by 011010 on 2026-10-15T00:02:15Z.
The overlap bot is right: #5968 (@MarcZX100) implements
sceAudio3dPortGetAttributesSupportedand 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:
sceAudio3dPortGetAttributesSupportedin favour of his.Depends on: #5968.I will push the rebased head once #5968 lands.
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 ownsceAudio3dPortGetAttributesSupportedor the tests for it, so the two PRs no longer conflict inExport.cpporGuestAudio3dPort.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.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:
main(with #5968) showing FIFA 21PPSA01327callingsceAudio3dBedWrite/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.main.core/libs/prx/libSceAudio3d/Export.cppconflicts: #5968 landed as a different commit, andb2cde4a0fchangedsceAudio3dPortPushto wait withPreciseSleepUntil(Windowssleep_untilwakes on a 15.6 ms step). This PR deletes that wait and relies on the blockingsceAudioOutOutputinstead. Please rebase and show on Windows that a blockingsceAudio3dPortPushstill runs at real time.docs/dev/debt/libSceAudio3d.mdunder "Unknown function info", one line each: the downmix coefficients (0.7071, LFE dropped,Mixer.hpp:21-57), the channel order, thegranularityreturn value ofsceAudio3dAudioOutOutput(Export.cpp:429),NOT_SUPPORTEDfor buffer modes other than 2 andNOT_READYon a full queue insceAudio3dPortAdvance(Export.cpp:153-154;mainthrows on a full queue). Say which reference each follows (shadPS4, KytyPS5, prosper); where none has a body, throw instead of guessing.NotImplementedstubs. Please split the stubs (they add nothing the title needs) from the bed path.Welcome back once the title log is in.
Imported from boykopovar/AnyPS5. Originally posted by 011010 on 2026-10-19T22:33:42Z.
Rebased onto current
mainand re-scoped to the bed path alone. Answering your four points one by one.1. Scope. The seventeen
NotImplementedstubs 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,sceAudio3dAudioOutOutputsandsceAudio3dAudioOutClose. 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.mdunder "Unknown function info", one entry each, and I went through the references to write them:DOWNMIX_CENTERandDOWNMIX_SURROUNDare 0.7071 and whoseDOWNMIX_LFEis 0, so itsif constexprthat 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.sceAudio3dAudioOutOutputfollows KytyPS5 and prosper, whosesceAudioOutOutputreturns the grain, and this project's ownsceAudioOutOutput, which returns the port'ssamplesNum. shadPS4 returns the total samples and fpPS4 returns 0; no console measurement settles it, so the difference is recorded rather than hidden.NOT_READYon a full queue follows shadPS4, the only reference with a body.This uncovered a bug. The branch had invented
AUDIO3D_ERROR_NOT_SUPPORTEDas0x80EA0005, which shadPS4's error enum namesOUT_OF_MEMORY; the unsupported buffer mode is0x80EA0008, 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.
sceAudioOutOutputblocks while the queue is over its target and waits withPreciseSleepUs, the high-resolution timerb2cde4a0fadded, 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_portpushes 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 msTARGET_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, issceAudio3dPortGetAttributesSupported, which #5968 already provided.I have asked for the log in a separate comment here with the exact steps, because the relinker's
--trace-importsrecords the calls the title makes to the libraries named inAPS5_TRACE_CALLSand prints them with their NIDs, so one run of the title withAPS5_TRACE_CALLS=libSceAudio3dsettles 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 totests/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.
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
libSceAudio3dexports the title actually calls, so that we can tell whether the bed path this pull request carries (sceAudio3dBedWrite,sceAudio3dBedWrite2and the newsceAudio3dPortPush) 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:
--trace-imports(Windows only, it conflicts with--lazy-binding).APS5_TRACE_CALLS=libSceAudio3din the environment.The report looks like this:
Posting that section for
libSceAudio3dis 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
libSceAudio3dneeds for any title, and the same--trace-importsrun would show the other libraries the title leans on.Thank you.
Imported from boykopovar/AnyPS5. Originally posted by 011010 on 2026-10-20T02:36:39Z.
Rebased onto
mainagain (d5bd6304c, 16 commits, no conflicts) and ran the head on Windows too, because a pull request never gets thelinuxorwindowsjob: inbuild.ymlboth run only on a push tomainor a manual dispatch, so this thread has only ever seenconventions,labels,reportand 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_portpassed 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.agc_driver_*write-watch/DCC tests that this GPU cannot run and thattools/check_skips.py --job windowstreats as skips. No audio test fails.Linux (Ubuntu 24.04 container, GCC 13.3)
ctest -R "audio"→ 48/48 passed;guest_audio3d_portpassed in 1.29 s.*Skippedwrite-watch test that needsUFFD_FEATURE_WP_ASYNC, absent from this container's 6.6 kernel.One bug found and fixed in this head. On Windows
guest_audio3d_mixerexited0xC0000135, DLL not found: the test linkslibcand loadslibc.prx, but unlike every other test in the tree that linkslibcit did not prepend the unpatched library directory toPATH.d5bd6304cadds the sameENVIRONMENT_MODIFICATIONblock its two neighbouring tests use. Without it, the first push tomainafter the merge would have failed thewindowsjob, which does run on a push.The title log is still the one thing this head cannot produce, and that request stands.
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.
main)docs/dev/debt/libSceAudio3d.mdL11Imported 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:
sceAudio3dBedWrite2stores the bed ing_port.bed, andsceAudio3dPortAdvancemixes 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-queueNOT_READY, queues each bed write (ConvertAndEnqueueintobed_queue) and consumes it when it mixes (pop_frontinProcessMixQueue). Please consume the bed on advance (clear it afterMixFrame, or queue the writes) and add a case toguest_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_SUPPORTEDthere, throwing would fit CONTRIBUTING better than an error code.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:
sceAudio3dBedWrite2wrote into a singleg_port.bedandsceAudio3dPortAdvancemixed 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::dequeof blocks now: eachsceAudio3dBedWrite2enqueues one, the queue is bounded byqueue_depthand returnsNOT_READYwhen full (shadPS4'sConvertAndEnqueuedoes the same againstparameters.queue_depth), andsceAudio3dPortAdvancepops 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.
sceAudio3dPortGetQueueLevelreports levels, and the frames leave throughsceAudio3dAudioOutOutputinto a real AudioOut port, sowrite a bed, advance twice, and check the second frame is silentcannot be asserted through the exported surface. Whatguest_audio3d_portchecks instead is the queue's behaviour, which is what the bug broke:queue_depth, require the next write to beNOT_READY;The silence itself is already covered where it is produced:
guest_audio3d_mixerasserts thatMixFramewith 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.
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_portaborted 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_exceptiontimed 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.BedWrite2enqueues, bounded byqueue_depth,NOT_READYwhen full;PortAdvanceconsumes one or mixes silence) fixes the replay and overwrite cases from the review, and the newCheckBedQueuepins both.Checked the mixer, bed validation, queueing and debt entries; merged.