fix(libSceAudioOut): play the PCM a port was given at the set when an AudioOut2 context advances #13998

Merged
alfalfa-star merged 4 commits from upstream-pr/13998 into main 2026-10-31 23:24:11 +00:00
alfalfa-star commented 2026-10-31 14:57:01 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by alfalfa-star on 2026-10-31T14:57:01Z.


What

With an SDL device, sceAudioOut2ContextAdvance read each port's buffer when it completed the grain. A grain given by a sceAudioOut2PortSetAttributes set now plays the copy of the buffer taken at that set (the copy #8098 already makes for buffers shared between ports). A port pointed once and rewritten in place still has its buffer read at Advance, so audio_out2_timing and the PPSA26358 case are unchanged. Contexts without Advance are unchanged.

Crash Bandicoot 4 (PPSA02433) has no sound in the menus or in game. Its Wwise 3D sink (sceaudio3d.prx) hands Wwise's 16 mix buffers to object ports (type 0x100), and Wwise clears them for the next frame before Advance. gdb with a write watchpoint on port 4's buffer, one frame:

WRITE pc 4b10d3c       (Wwise mix)          -0.0017, 0.0001, 0.0031, 0.0059
WRITE akcompressor+668                       -0.0017, ...
WRITE akpeaklimiter+162d                     -0.0131, ...
SET   port4 pcm 202bfe0880                   -0.0131, -0.0127, -0.0099, -0.0073
WRITE libc.prx+fe73    (memset)              0, 0, 0, 0
ADVANCE ctx (Wwise)                          0, 0, 0, 0

So every grain was snapshotted as silence (mixed data peak 0.0000 with 16 ports per grain); with the change the same scene mixes peaks of 0.2-0.9.

Tested

  • Linux (Arch), PPSA02433: title music, menu sounds and gameplay audio play (confirmed by ear).
  • New TestAdvanceKeepsTheGrainSetBeforeTheBufferIsCleared in audio_out2_port_buffers fails without the change and passes with it.
  • All 59 audio_out* tests pass. tools/check_conventions.py --base upstream/main passes.
  • #13988 adds a test next to the new one in AudioOut2PortBuffers.cpp. #13988 goes first; this PR will be rebased on main after it lands and the audio_out* tests rerun.

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: #13988
  • Fixes: none
  • Unblocks: PPSA02433 #9065
  • GPUs tested: n/a
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5098671454 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/13998). Originally posted by [alfalfa-star](https://github.com/alfalfa-star) on 2026-10-31T14:57:01Z. --- ### What With an SDL device, `sceAudioOut2ContextAdvance` read each port's buffer when it completed the grain. A grain given by a `sceAudioOut2PortSetAttributes` set now plays the copy of the buffer taken at that set (the copy #8098 already makes for buffers shared between ports). A port pointed once and rewritten in place still has its buffer read at Advance, so `audio_out2_timing` and the PPSA26358 case are unchanged. Contexts without Advance are unchanged. Crash Bandicoot 4 (PPSA02433) has no sound in the menus or in game. Its Wwise 3D sink (`sceaudio3d.prx`) hands Wwise's 16 mix buffers to object ports (type 0x100), and Wwise clears them for the next frame before Advance. gdb with a write watchpoint on port 4's buffer, one frame: ``` WRITE pc 4b10d3c (Wwise mix) -0.0017, 0.0001, 0.0031, 0.0059 WRITE akcompressor+668 -0.0017, ... WRITE akpeaklimiter+162d -0.0131, ... SET port4 pcm 202bfe0880 -0.0131, -0.0127, -0.0099, -0.0073 WRITE libc.prx+fe73 (memset) 0, 0, 0, 0 ADVANCE ctx (Wwise) 0, 0, 0, 0 ``` So every grain was snapshotted as silence (mixed data peak 0.0000 with 16 ports per grain); with the change the same scene mixes peaks of 0.2-0.9. ### Tested - Linux (Arch), PPSA02433: title music, menu sounds and gameplay audio play (confirmed by ear). - New `TestAdvanceKeepsTheGrainSetBeforeTheBufferIsCleared` in `audio_out2_port_buffers` fails without the change and passes with it. - All 59 `audio_out*` tests pass. `tools/check_conventions.py --base upstream/main` passes. - #13988 adds a test next to the new one in `AudioOut2PortBuffers.cpp`. #13988 goes first; this PR will be rebased on `main` after it lands and the `audio_out*` tests rerun. ### 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: #13988 - [x] Fixes: none - [x] Unblocks: PPSA02433 #9065 - [x] GPUs tested: n/a - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
MarcZX10 commented 2026-10-31 15:02:46 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-31T15:02:46Z.

Review: APPROVED


Reviewed — looks good

The exact-head change snapshots each queued PCM grain at PortSetAttributes, and the Windows CI job built and ran the focused buffer test.

What I ran

Reviewed head c34ab0258d0647effd5033cee7ca06e489d931c5 against base 73f4f7e06e4f210a8c6570e335fd654dc0a86134; its current-base merge preview is clean. Environment for local checks: Debian Linux x86_64, Python 3.11.2, GCC 12.2.0. I did not build locally.

python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 13998
git diff --check 73f4f7e06e4f210a8c6570e335fd654dc0a86134...c34ab0258d0647effd5033cee7ca06e489d931c5
gh run view 41212490720 --repo boykopovar/AnyPS5 --job 124570240133 --log

Results

Check Result
Diff check, conventions, PR template Passed.
Current-base merge preview Clean.
Windows CI Passed; the job built and ran audio_out2_port_buffers_tests.
Linux and specialized product jobs Skipped by workflow.
Local build/CTest Not run.
Author-reported Linux/title check The author reports audio playback restored in PPSA02433, all 59 audio_out* tests passing, and a negative control where the new test fails without the change; I did not reproduce these runs.
Unedited Windows job output
[2/4] Building CXX object core/libs/prx/libSceAudioOut/CMakeFiles/audio_out2_port_buffers_tests.dir/tests/AudioOut2PortBuffers.cpp.obj
[3/4] Linking CXX executable tests\audio_out2_port_buffers_tests.exe
Guest core/libs tests:
audio_out2_port_buffers_tests

Findings

Blocking

None found in the reviewed change.

Non-blocking

PR #13988 also changes the AudioOut2 buffer tests. A pairwise merge preview of the two current heads reports a content conflict in AudioOut2PortBuffers.cpp; this does not affect #13998's clean merge with current main, and the PR description already notes that the second PR to land will need conflict resolution.

Sources

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5723447439 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/13998#pullrequestreview-5723447439). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-31T15:02:46Z. **Review:** APPROVED --- # Reviewed — looks good The exact-head change snapshots each queued PCM grain at `PortSetAttributes`, and the Windows CI job built and ran the focused buffer test. ## What I ran Reviewed head `c34ab0258d0647effd5033cee7ca06e489d931c5` against base `73f4f7e06e4f210a8c6570e335fd654dc0a86134`; its current-base merge preview is clean. Environment for local checks: Debian Linux x86_64, Python 3.11.2, GCC 12.2.0. I did not build locally. ```sh python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 13998 git diff --check 73f4f7e06e4f210a8c6570e335fd654dc0a86134...c34ab0258d0647effd5033cee7ca06e489d931c5 gh run view 41212490720 --repo boykopovar/AnyPS5 --job 124570240133 --log ``` ## Results | Check | Result | |---|---| | Diff check, conventions, PR template | Passed. | | Current-base merge preview | Clean. | | Windows CI | Passed; the job built and ran `audio_out2_port_buffers_tests`. | | Linux and specialized product jobs | Skipped by workflow. | | Local build/CTest | Not run. | | Author-reported Linux/title check | The author reports audio playback restored in PPSA02433, all 59 `audio_out*` tests passing, and a negative control where the new test fails without the change; I did not reproduce these runs. | <details><summary>Unedited Windows job output</summary> ```text [2/4] Building CXX object core/libs/prx/libSceAudioOut/CMakeFiles/audio_out2_port_buffers_tests.dir/tests/AudioOut2PortBuffers.cpp.obj [3/4] Linking CXX executable tests\audio_out2_port_buffers_tests.exe Guest core/libs tests: audio_out2_port_buffers_tests ``` </details> ## Findings ### Blocking None found in the reviewed change. ### Non-blocking PR #13988 also changes the AudioOut2 buffer tests. A pairwise merge preview of the two current heads reports a content conflict in `AudioOut2PortBuffers.cpp`; this does not affect #13998's clean merge with current `main`, and the PR description already notes that the second PR to land will need conflict resolution. ## Sources - [PCM snapshot selection and capture at this head](https://github.com/boykopovar/AnyPS5/blob/c34ab0258d0647effd5033cee7ca06e489d931c5/core/libs/prx/libSceAudioOut/src/AudioOut2Port.cpp#L106-L131). - [Regression test at this head](https://github.com/boykopovar/AnyPS5/blob/c34ab0258d0647effd5033cee7ca06e489d931c5/core/libs/prx/libSceAudioOut/tests/AudioOut2PortBuffers.cpp#L192-L211).
MarcZX10 commented 2026-10-31 15:34:16 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-31T15:34:16Z.

Review: CHANGES_REQUESTED


Reviewed — changes requested

The PR’s own description identifies a merge conflict with #13988, but the checklist says Depends on: none; repository policy requires agreeing on and declaring the landing order.

What I ran

Reviewed head c34ab0258d0647effd5033cee7ca06e489d931c5 against base 73f4f7e06e4f210a8c6570e335fd654dc0a86134. The individual preview against current main 474030e58424fefdb65e5df9f3820810fbb4553c was clean. Environment: Linux x86_64, Python 3.11.2, Git 2.39.5; no local build or tests.

python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 13998
git diff --check 73f4f7e06e4f210a8c6570e335fd654dc0a86134...c34ab0258d0647effd5033cee7ca06e489d931c5
python3 tools/pr_stack_check.py 13998 --repo boykopovar/AnyPS5
git merge-tree --write-tree c34ab0258d0647effd5033cee7ca06e489d931c5 11f217b14fbc293d8ce3e9b98b5c1cb4b924eb0e
gh api repos/boykopovar/AnyPS5/commits/c34ab0258d0647effd5033cee7ca06e489d931c5/check-runs --jq '.check_runs[] | [.name,.status,(.conclusion // "pending")] | @tsv'

Results

Check Result
Diff whitespace Passed
Repository conventions and PR template Passed
Individual merge preview against current main Clean
Pairwise merge preview with #13988 Conflict in AudioOut2PortBuffers.cpp
Hosted Windows changed guest-test build/run step Passed
Hosted conventions, eligibility, intake, labels, library portability, report Passed
Hosted Linux and other specialized jobs Skipped
Author-reported Linux audio tests and PPSA02433 playback Reported passing; not independently run here
Precheck ABI/test-quality helpers Unavailable in the isolated PR snapshot; neither is a test result
Unedited check output

Diff check exited 0 with no output.

Conventions:

All conventions checks passed.

Individual merge preview:

- PR #13998: **clean** against current base; head `c34ab0258d0647effd5033cee7ca06e489d931c5`; changed paths: none reported

No declared PR dependencies were found in the target PR chain.

Pairwise merge preview with #13988:

CONFLICT (content): Merge conflict in core/libs/prx/libSceAudioOut/tests/AudioOut2PortBuffers.cpp

Hosted check runs:

labels	completed	success
conventions	completed	success
register-context	completed	skipped
write-watch	completed	skipped
linux	completed	skipped
relinker-asan	completed	skipped
relinker	completed	skipped
windows	completed	success
conventions	completed	success
eligibility	completed	success
labels	completed	success
intake	completed	success
report	completed	success
library-portability	completed	success

The precheck could not find its audit helpers in the isolated snapshot:

/usr/bin/python3: can't open file '/tmp/anyps5-pr-precheck/boykopovar-AnyPS5-pr-13998-c34ab0258d06/head-c34ab0258d06-10dbd69c/tools/pr_abi_audit.py': [Errno 2] No such file or directory
/usr/bin/python3: can't open file '/tmp/anyps5-pr-precheck/boykopovar-AnyPS5-pr-13998-c34ab0258d06/head-c34ab0258d06-10dbd69c/tools/pr_test_quality.py': [Errno 2] No such file or directory

Findings

Blocking

Landing order for #13988 is unresolved. The two open heads have a real content conflict in the same test file, and this PR's body states that whichever lands second needs a rebase while declaring no dependency. Choose which PR lands first and declare that order with the appropriate Depends on entry on the later PR. Rebase the later PR after the first lands and rerun its tests.

Sources

Not verified

I did not build or run tests locally. The Linux test and title-audio results are author-reported; the hosted Windows job passed its changed guest-test build/run step. I did not measure behavior on a physical PS5.

To get this to a good state

Choose a landing order for the two PRs, declare the dependency in the later PR, and rebase/test it after its dependency lands. I will rerun the same checks on the updated head.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5723577807 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/13998#pullrequestreview-5723577807). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-31T15:34:16Z. **Review:** CHANGES_REQUESTED --- # Reviewed — changes requested The PR’s own description identifies a merge conflict with #13988, but the checklist says `Depends on: none`; repository policy requires agreeing on and declaring the landing order. ## What I ran Reviewed head `c34ab0258d0647effd5033cee7ca06e489d931c5` against base `73f4f7e06e4f210a8c6570e335fd654dc0a86134`. The individual preview against current `main` `474030e58424fefdb65e5df9f3820810fbb4553c` was clean. Environment: Linux x86_64, Python 3.11.2, Git 2.39.5; no local build or tests. ```sh python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 13998 git diff --check 73f4f7e06e4f210a8c6570e335fd654dc0a86134...c34ab0258d0647effd5033cee7ca06e489d931c5 python3 tools/pr_stack_check.py 13998 --repo boykopovar/AnyPS5 git merge-tree --write-tree c34ab0258d0647effd5033cee7ca06e489d931c5 11f217b14fbc293d8ce3e9b98b5c1cb4b924eb0e gh api repos/boykopovar/AnyPS5/commits/c34ab0258d0647effd5033cee7ca06e489d931c5/check-runs --jq '.check_runs[] | [.name,.status,(.conclusion // "pending")] | @tsv' ``` ## Results | Check | Result | |---|---| | Diff whitespace | Passed | | Repository conventions and PR template | Passed | | Individual merge preview against current `main` | Clean | | Pairwise merge preview with #13988 | Conflict in `AudioOut2PortBuffers.cpp` | | Hosted Windows changed guest-test build/run step | Passed | | Hosted conventions, eligibility, intake, labels, library portability, report | Passed | | Hosted Linux and other specialized jobs | Skipped | | Author-reported Linux audio tests and PPSA02433 playback | Reported passing; not independently run here | | Precheck ABI/test-quality helpers | Unavailable in the isolated PR snapshot; neither is a test result | <details><summary>Unedited check output</summary> Diff check exited 0 with no output. Conventions: ```text All conventions checks passed. ``` Individual merge preview: ```text - PR #13998: **clean** against current base; head `c34ab0258d0647effd5033cee7ca06e489d931c5`; changed paths: none reported No declared PR dependencies were found in the target PR chain. ``` Pairwise merge preview with #13988: ```text CONFLICT (content): Merge conflict in core/libs/prx/libSceAudioOut/tests/AudioOut2PortBuffers.cpp ``` Hosted check runs: ```text labels completed success conventions completed success register-context completed skipped write-watch completed skipped linux completed skipped relinker-asan completed skipped relinker completed skipped windows completed success conventions completed success eligibility completed success labels completed success intake completed success report completed success library-portability completed success ``` The precheck could not find its audit helpers in the isolated snapshot: ```text /usr/bin/python3: can't open file '/tmp/anyps5-pr-precheck/boykopovar-AnyPS5-pr-13998-c34ab0258d06/head-c34ab0258d06-10dbd69c/tools/pr_abi_audit.py': [Errno 2] No such file or directory /usr/bin/python3: can't open file '/tmp/anyps5-pr-precheck/boykopovar-AnyPS5-pr-13998-c34ab0258d06/head-c34ab0258d06-10dbd69c/tools/pr_test_quality.py': [Errno 2] No such file or directory ``` </details> ## Findings ### Blocking **Landing order for #13988 is unresolved.** The two open heads have a real content conflict in the same test file, and this PR's body states that whichever lands second needs a rebase while declaring no dependency. Choose which PR lands first and declare that order with the appropriate `Depends on` entry on the later PR. Rebase the later PR after the first lands and rerun its tests. ## Sources - [Contribution rule requiring PR overlap order and `Depends on`](https://github.com/boykopovar/AnyPS5/blob/73f4f7e06e4f210a8c6570e335fd654dc0a86134/CONTRIBUTING.md#L67) - [This PR’s test insertion](https://github.com/boykopovar/AnyPS5/blob/c34ab0258d0647effd5033cee7ca06e489d931c5/core/libs/prx/libSceAudioOut/tests/AudioOut2PortBuffers.cpp#L189-L219) - [#13988’s overlapping test insertion](https://github.com/boykopovar/AnyPS5/blob/11f217b14fbc293d8ce3e9b98b5c1cb4b924eb0e/core/libs/prx/libSceAudioOut/tests/AudioOut2PortBuffers.cpp#L189-L219) ## Not verified I did not build or run tests locally. The Linux test and title-audio results are author-reported; the hosted Windows job passed its changed guest-test build/run step. I did not measure behavior on a physical PS5. ## To get this to a good state Choose a landing order for the two PRs, declare the dependency in the later PR, and rebase/test it after its dependency lands. I will rerun the same checks on the updated head.
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!13998
No description provided.