feat(audio3d): implement the port queue #740
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/740"
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 adriadam10 on 2026-10-05T18:58:26Z.
What
Implements the libSceAudio3d port queue:
sceAudio3dInitialize,sceAudio3dPortOpen,sceAudio3dPortClose,sceAudio3dPortSetAttribute,sceAudio3dPortGetQueueLevel,sceAudio3dPortAdvance,sceAudio3dPortPush.Sources, per behaviour:
hle_audio_spatial.cpp), which reads them from the PS5 module: one port (id 0, a second open isOUT_OF_RESOURCES),NOT_READYbeforeInitializechecked before the arguments, user id must be0xFF, parameter sizes 0x20/0x28 exactly (no masking), 48 kHz only, granularity a multiple of 256, non-zero objects and depth, buffer mode ≤ 2, 2 or 3 beds; a failed open leaves*iduntouched;Close/per-port calls returnINVALID_PORT(0x80EA0002) for anything but the open port. Error values also match shadPS4'saudio3d_error.h.audio3d.cpp) and shadPS4 agree that a frame is queued byAdvance,Pushhands the queued frames over, and a blocking push (1) returns once a slot is free. Here each pushed frame plays forgranularity / 48000s (KytyPS5'sdata_delay), so the level drains at the port's rate and a blocking push actually paces the caller. prosper's port is a sink whose queue always reads empty and does not pace (it notes a title's audio thread spins on it); this follows KytyPS5 instead.0x10001late reverb level,0x10002downmix spread radius,0x10003downmix spread height aware), size 4. They are accepted and have no effect (listed in Silent stubs).Where the references disagree or say nothing, the call throws (listed under Unknown function info):
Initialize:NOT_READYin shadPS4, 0 in prosper;Advanceon a full queue:NOT_READYin shadPS4, unhandled in KytyPS5;The port produces no sound: AnyPS5's libSceAudio3d has no bed/object exports (
BedWrite,ObjectReserve...) to feed it, soPushonly paces. Listed in Silent stubs.sceAudio3dTerminateis not exported, so there is no Initialize/Terminate pair to complete.Tested
Linux, GCC Release. New
guest_audio3d_port(registered in ctest): every error path above (before/afterInitialize, each rejected parameter with*idunchanged, the throwing cases, port 1, double close), queue levels through twoAdvancecalls, a blocking push that waits at least one frame (6144-sample granularity = 128 ms) and returns with one free slot, an async push that does not wait, and the queue draining to empty at the port's rate. Fails onmain(the stubs throw). Negative checks (each made the test fail): no sleep in blocking push,NOT_READYafter the argument check, noOUT_OF_RESOURCES, frames never retired, rate not checked, no throw on a full queue, close not resetting the port, 3 beds accepted, attribute size not checked, reserved not checked, wrong port id written.guest_audio3d_parametersstill passes.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.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-05T18:59:54Z.
Progress report (
bc24783→42869ef)📈 System libraries: 79.75% (+0.21%, +7 implemented functions)
✅ 7 implemented
sceAudio3dInitializesceAudio3dPortAdvancesceAudio3dPortClosesceAudio3dPortGetQueueLevelsceAudio3dPortOpensceAudio3dPortPushsceAudio3dPortSetAttributeImported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-05T20:30:21Z.
Thanks for this. The Windows job fails in the new test (run 37359993426):
guest_audio3d_portaborts at "blocking push returns with one free slot", right after the blockingsceAudio3dPortPush.The elapsed-time check just before it allows 2 ms of slack, but the level check doesn't, so the push most likely returned a little before
wait_until. For a steady clock, libstdc++'ssleep_untilcallssleep_foronce and doesn't check the time again, and the Windows sleep can come back slightly early. In that case the first frame is still inplayingand the level is still full, which a title would see too, not only the test. Looping untilClock::now() >= wait_untilinsceAudio3dPortPushshould fix both.The rest looks good to me: Linux passes, the test fails on main's code, and the unsupported modes and attributes throw.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-05T22:28:37Z.
Thanks, that's it.
sceAudio3dPortPushnow loops onClock::now() < wait_untilaroundsleep_until, so a blocking push never returns before the slot frees. Rebased on currentmain;guest_audio3d_portandguest_audio3d_parameterspass (5 runs in a row, Linux).