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

Closed
LuisAguilarDev wants to merge 1 commit from upstream-pr/7719 into main
LuisAguilarDev commented 2026-10-19 02:46:53 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by LuisAguilarDev on 2026-10-19T02:46:53Z.


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

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4915091723 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7719). Originally posted by [LuisAguilarDev](https://github.com/LuisAguilarDev) on 2026-10-19T02:46:53Z. --- ### 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)
github-actions[bot] commented 2026-10-19 02:47:10 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-19T02:47:10Z.


Thank you for your contribution! Authors with no pull requests merged into main can have 1 open pull request at a time, authors with at least 1 merged can have 20, and from 20 merged there is no limit. This PR has been automatically closed and labeled "open PR limit" because that limit was reached. This is not a judgment of the quality of your changes: reopen it once one of your open pull requests is merged or closed.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6258563626 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7719#issuecomment-6258563626). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-19T02:47:10Z. --- Thank you for your contribution! Authors with no pull requests merged into `main` can have 1 open pull request at a time, authors with at least 1 merged can have 20, and from 20 merged there is no limit. This PR has been automatically closed and labeled "open PR limit" because that limit was reached. This is not a judgment of the quality of your changes: reopen it once one of your open pull requests is merged or closed.
johandavidcm commented 2026-10-19 14:06:23 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by johandavidcm on 2026-10-19T14:06:23Z.


@LuisAguilarDev Yakuza 0 Director's Cut (PPSA31327, #6722) has the same pattern and is silent on main; 8d1fc2b30 brings its sound back. Windows 11 Pro 26200, WinLibs GCC 15.2.0 r7, Release, RTX 4070 (617.42), on main 40393b0f9 with #6572 and #7381 (the title needs both to get past its first cutscene).

  • The title creates two MAIN ports (type 0, 12 float channels; flags 0x0 on user 2, flags 0x1 on user 3) and gives both the same PCM pointer each grain, then calls sceAudioOut2ContextAdvance and sceAudioOut2ContextPush, about 188 times per second.
  • Without this change: APS5_TRACE_AUDIOOUT2 reports mix peak 0.000 in every second, and a local probe at capture found all 3072 floats of the shared buffer zero at Advance in 30 of 30 samples.
  • With this change: mix peak is 0.003 to 0.173 in 27 of 42 seconds (the first 9, the logos, are silent) and the menus are audible and smooth. The opening cutscene's audio is choppy, but the push rate stays at 186-188/s with 0 primes and 0 dropped, so that looks separate: the title runs at a few FPS there.
  • ctest -R '^audio_out': 17 of 17 pass on that tree.

The bot closed this only for the open-PR limit, and #6592 has merged since, so it can be reopened now; it unblocks sound for PPSA31327 too.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6269152692 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7719#issuecomment-6269152692). Originally posted by [johandavidcm](https://github.com/johandavidcm) on 2026-10-19T14:06:23Z. --- @LuisAguilarDev Yakuza 0 Director's Cut (PPSA31327, #6722) has the same pattern and is silent on `main`; 8d1fc2b30 brings its sound back. Windows 11 Pro 26200, WinLibs GCC 15.2.0 r7, Release, RTX 4070 (617.42), on `main` 40393b0f9 with #6572 and #7381 (the title needs both to get past its first cutscene). - The title creates two MAIN ports (type 0, 12 float channels; flags 0x0 on user 2, flags 0x1 on user 3) and gives both the same PCM pointer each grain, then calls `sceAudioOut2ContextAdvance` and `sceAudioOut2ContextPush`, about 188 times per second. - Without this change: `APS5_TRACE_AUDIOOUT2` reports `mix peak 0.000` in every second, and a local probe at capture found all 3072 floats of the shared buffer zero at `Advance` in 30 of 30 samples. - With this change: `mix peak` is 0.003 to 0.173 in 27 of 42 seconds (the first 9, the logos, are silent) and the menus are audible and smooth. The opening cutscene's audio is choppy, but the push rate stays at 186-188/s with 0 primes and 0 dropped, so that looks separate: the title runs at a few FPS there. - `ctest -R '^audio_out'`: 17 of 17 pass on that tree. The bot closed this only for the open-PR limit, and #6592 has merged since, so it can be reopened now; it unblocks sound for PPSA31327 too. AI-assisted: yes

Pull request closed

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!7719
No description provided.