Skip to content

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

Closed
LuisAguilarDev wants to merge 1 commit into
boykopovar:mainfrom
LuisAguilarDev:fix/audioout2-silent-ports
Closed

LuisAguilarDev wants to merge 1 commit into
boykopovar:mainfrom
LuisAguilarDev:fix/audioout2-silent-ports

Conversation

@LuisAguilarDev

Copy link
Copy Markdown
Contributor

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 fix(audio): retain completed AudioOut2 grains until pushed #6216 and fix(libSceAudioOut): count completed AudioOut2 grains in the queue level #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 Dragon Ball Xenoverse 2 (PPSA08587) on Windows #6591
  • GPUs tested: n/a
  • AI-assisted: yes

🤖 Generated with Claude Code

A title can fill one buffer and hand it to several ports in turn before
advancing the context. Reading the buffer only at push time gave every
port the contents set last, so the earlier ports played silence. Each
set now copies the grain, and a grain whose buffer is handed to another
port afterwards plays its copy. Buffers no other port is given are still
read at push time.
@github-actions github-actions Bot added unblocks title Names a title ID on the Unblocks line open PR limit Closed over the open PR limit: 1 without merged PRs, 20 with at least 1, none from 20 labels Oct 19, 2026
@github-actions

Copy link
Copy Markdown

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.

@github-actions github-actions Bot closed this Oct 19, 2026
@johandavidcm

Copy link
Copy Markdown
Contributor

@LuisAguilarDev Yakuza 0 Director's Cut (PPSA31327, #6722) has the same pattern and is silent on main; 8d1fc2b brings its sound back. Windows 11 Pro 26200, WinLibs GCC 15.2.0 r7, Release, RTX 4070 (617.42), on main 40393b0 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

open PR limit Closed over the open PR limit: 1 without merged PRs, 20 with at least 1, none from 20 unblocks title Names a title ID on the Unblocks line

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants