fix(audioout2): keep each port's grain when ports share a buffer #8098

Merged
LuisAguilarDev merged 1 commit from upstream-pr/8098 into main 2026-10-27 23:59:21 +00:00
LuisAguilarDev commented 2026-10-19 21:36:55 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by LuisAguilarDev on 2026-10-19T21:36:55Z.


What

Dragon Ball Xenoverse 2 (PPSA08587) plays no sound. It fills one PCM buffer and hands it to each of its three AudioOut2 ports in turn (sceAudioOut2PortSetAttributes, attribute 0), rewriting the buffer between the sets, then advances the context. The grain is read from the buffer only when it is captured (at sceAudioOut2ContextAdvance, or at push without an advance), so every port gets the contents written last and the earlier ports play the last port's data, here silence.

Each set now also copies the grain from the buffer. Once another port of the same context is given the same buffer, the grains already queued with it, and its repeat, play that copy instead of the buffer's later contents. A buffer no other port is given is still read when the grain is captured, as before. The queued-buffer and repeat rules are unchanged. The sceAudioOut2PortSetAttributes entry in docs/dev/debt/libSceAudioOut.md describes the copy; the console behaviour for a buffer shared by several ports is not documented.

Tested

  • Windows 11, MinGW-w64 GCC, Release:
    • New TestBufferReusedAcrossPortsKeepsEachPortsGrain in audio_out2_port_buffers, with and without sceAudioOut2ContextAdvance. Without the AudioOut2Port.cpp change, audio_out2_port_buffers aborts in its first case (without an advance), so current main still plays the last port's contents on every port.
    • All 17 audio_out* tests pass; audio_out2_port_buffers in 2.5 s.
    • tools/check_conventions.py --base upstream/main and git diff --check pass.
  • PPSA08587, measured on a build of an earlier main (before #6216 and #6474): the mix peak was 0.000 in 82 of 82 seconds before; with this change it carries audio (peak 0.24-0.52) in 63 of 82 seconds, and the game is audible.

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

🤖 Generated with Claude Code

Replaces #7719, which GitHub does not allow to reopen after the open PR limit closed it. Same branch and commit; the discussion is there.

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4927760382 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8098). Originally posted by [LuisAguilarDev](https://github.com/LuisAguilarDev) on 2026-10-19T21:36:55Z. --- ### What Dragon Ball Xenoverse 2 (PPSA08587) plays no sound. It fills one PCM buffer and hands it to each of its three AudioOut2 ports in turn (`sceAudioOut2PortSetAttributes`, attribute 0), rewriting the buffer between the sets, then advances the context. The grain is read from the buffer only when it is captured (at `sceAudioOut2ContextAdvance`, or at push without an advance), so every port gets the contents written last and the earlier ports play the last port's data, here silence. Each set now also copies the grain from the buffer. Once another port of the same context is given the same buffer, the grains already queued with it, and its repeat, play that copy instead of the buffer's later contents. A buffer no other port is given is still read when the grain is captured, as before. The queued-buffer and repeat rules are unchanged. The `sceAudioOut2PortSetAttributes` entry in `docs/dev/debt/libSceAudioOut.md` describes the copy; the console behaviour for a buffer shared by several ports is not documented. ### Tested - Windows 11, MinGW-w64 GCC, Release: - New `TestBufferReusedAcrossPortsKeepsEachPortsGrain` in `audio_out2_port_buffers`, with and without `sceAudioOut2ContextAdvance`. Without the `AudioOut2Port.cpp` change, `audio_out2_port_buffers` aborts in its first case (without an advance), so current `main` still plays the last port's contents on every port. - All 17 `audio_out*` tests pass; `audio_out2_port_buffers` in 2.5 s. - `tools/check_conventions.py --base upstream/main` and `git diff --check` pass. - PPSA08587, measured on a build of an earlier `main` (before #6216 and #6474): the mix peak was 0.000 in 82 of 82 seconds before; with this change it carries audio (peak 0.24-0.52) in 63 of 82 seconds, and the game is audible. ### 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 - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's technical 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] Fixes: none - [x] Unblocks: PPSA08587 #6591 - [x] GPUs tested: n/a - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code) Replaces #7719, which GitHub does not allow to reopen after the open PR limit closed it. Same branch and commit; the discussion is there.
LuisAguilarDev commented 2026-10-19 21:39:19 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by LuisAguilarDev on 2026-10-19T21:39:19Z.


@johandavidcm thanks im glad it helps the sound of other games im reopening this PR

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6277982409 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8098#issuecomment-6277982409). Originally posted by [LuisAguilarDev](https://github.com/LuisAguilarDev) on 2026-10-19T21:39:19Z. --- @johandavidcm thanks im glad it helps the sound of other games im reopening this PR
johandavidcm commented 2026-10-21 14:16:46 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by johandavidcm on 2026-10-21T14:16:46Z.


Retested on current main with Yakuza 0 Director's Cut (PPSA31327, #6722).

Setup:

  • Build: main 80565c594 merged with this PR's head c1929ab9b, with no conflicts.
  • System: Windows 11, Ryzen 7 7800X3D, RTX 4070 (NVIDIA 617.42).
  • Run: a 100 s boot with APS5_TRACE_AUDIOOUT2=1.

Result:

  • The title still writes both MAIN ports from one shared buffer.
  • With this PR, mix peak is non-zero in 72 of the 98 one-second summaries. The first seconds of boot are silent.
  • Pushes stay at about 188/s, with 0 primes and 0 dropped.
  • In my earlier runs without this PR (main b7fc3d324), every summary read mix peak 0.000. I did not rerun that today.
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6318312640 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8098#issuecomment-6318312640). Originally posted by [johandavidcm](https://github.com/johandavidcm) on 2026-10-21T14:16:46Z. --- Retested on current `main` with Yakuza 0 Director's Cut (PPSA31327, #6722). **Setup:** - Build: `main` 80565c594 merged with this PR's head c1929ab9b, with no conflicts. - System: Windows 11, Ryzen 7 7800X3D, RTX 4070 (NVIDIA 617.42). - Run: a 100 s boot with `APS5_TRACE_AUDIOOUT2=1`. **Result:** - The title still writes both MAIN ports from one shared buffer. - With this PR, `mix peak` is non-zero in 72 of the 98 one-second summaries. The first seconds of boot are silent. - Pushes stay at about 188/s, with 0 primes and 0 dropped. - In my earlier runs without this PR (main b7fc3d324), every summary read `mix peak 0.000`. I did not rerun that today.
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!8098
No description provided.