fix(libSceAudioOut): report the port's channel count from sceAudioOut2PortGetState #4778

Merged
xXPBSXx merged 1 commit from upstream-pr/4778 into main 2026-10-14 17:32:59 +00:00
xXPBSXx commented 2026-10-12 21:35:47 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-12T21:35:47Z.


What

sceAudioOut2PortGetState reported the two channels of the host output for every port. It now reports the channel count of the port's data format, and clears the whole state first so the reserved fields no longer keep the caller's stack contents. Output (main), volume (127), reroute counter and flags are unchanged.

The channel count follows SharpEmu, another emulator. There is no console measurement for it; this is recorded in docs/dev/debt/libSceAudioOut.md.

New test audio_out2_device_state covers sceAudioOut2PortGetState (mono, stereo float and S16, 7.1, 7.1.4; invalid and destroyed handle; null state), sceAudioOut2GetSpeakerInfo and sceAudioOut2GetSystemState (null checks and reported values). None of the three had a test before.

Related to #4317 (ASTRO BOT PPSA21564, ASTRO's PLAYROOM PPSA01284: assertion prop->m_pParent == this). That issue has an A/B in which the reported AudioOut2 state decides the assertion, but it has not isolated which field; GetSpeakerInfo and output already match on main, so the channel count is the only remaining difference to the values described there. This PR does not claim to fix the assertion.

Tested

Windows 10 (19045), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release, built and run on main ffa198407:

  • audio_out2_device_state, audio_out2_port_layouts, audio_out2_port_buffers, audio_out2_pad_mix, audio_out2_latency and audio_out2_timing pass (6 of 6).

  • audio_out2_device_state fails without the change to AudioOut2Port.cpp (the mono port reports 2 channels).

  • The branch is rebased onto main 584cc4c57 without a conflict in the code (TechnicalDebt.md moved to docs/dev/debt/, so the entry is in debt/libSceAudioOut.md). I did not rebuild on that main: it needs the new libusb-cmake submodule, which is not available here. python tools/check_conventions.py --base upstream/main passes on the rebased branch.

  • The current head 72fae2087 is based on 6d7b87370, a later rebase than the one described above; it was not rebuilt (not recorded). git merge-tree of it against main 068ab2aba (13 October) is clean. The overlap bot lists #5119 for docs/dev/debt/libSceAudioOut.md L18, the debt file this change also touches; whichever lands second needs a small rebase there.

  • No title run; ASTRO BOT and ASTRO's PLAYROOM are not available here. Linux not tested. Ports of other types (pad routes) are not covered by the test; output stays main for them, as before. A search of open PRs for sceAudioOut2PortGetState found only this one.

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 in TechnicalDebt

  • No notes, investigation .md files or images added to the repository

  • New third-party code is a submodule built from source (none added)

  • Generic behaviour, not specific to one title

  • Depends on: none

  • Unblocks: none

  • AI-assisted: yes

AI-assisted (Claude Code).

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4835266371 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4778). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-12T21:35:47Z. --- ### What `sceAudioOut2PortGetState` reported the two channels of the host output for every port. It now reports the channel count of the port's data format, and clears the whole state first so the reserved fields no longer keep the caller's stack contents. Output (main), volume (127), reroute counter and flags are unchanged. The channel count follows [SharpEmu](https://github.com/sharpemu/sharpemu/blob/main/src/SharpEmu.Libs/Audio/AudioOut2Exports.cs), another emulator. There is no console measurement for it; this is recorded in `docs/dev/debt/libSceAudioOut.md`. New test `audio_out2_device_state` covers `sceAudioOut2PortGetState` (mono, stereo float and S16, 7.1, 7.1.4; invalid and destroyed handle; null state), `sceAudioOut2GetSpeakerInfo` and `sceAudioOut2GetSystemState` (null checks and reported values). None of the three had a test before. Related to #4317 (ASTRO BOT PPSA21564, ASTRO's PLAYROOM PPSA01284: assertion `prop->m_pParent == this`). That issue has an A/B in which the reported AudioOut2 state decides the assertion, but it has not isolated which field; `GetSpeakerInfo` and `output` already match on `main`, so the channel count is the only remaining difference to the values described there. This PR does not claim to fix the assertion. ### Tested Windows 10 (19045), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release, built and run on `main` `ffa198407`: - `audio_out2_device_state`, `audio_out2_port_layouts`, `audio_out2_port_buffers`, `audio_out2_pad_mix`, `audio_out2_latency` and `audio_out2_timing` pass (6 of 6). - `audio_out2_device_state` fails without the change to `AudioOut2Port.cpp` (the mono port reports 2 channels). - The branch is rebased onto `main` `584cc4c57` without a conflict in the code (`TechnicalDebt.md` moved to `docs/dev/debt/`, so the entry is in `debt/libSceAudioOut.md`). I did not rebuild on that `main`: it needs the new `libusb-cmake` submodule, which is not available here. `python tools/check_conventions.py --base upstream/main` passes on the rebased branch. - The current head `72fae2087` is based on `6d7b87370`, a later rebase than the one described above; it was not rebuilt (not recorded). `git merge-tree` of it against `main` `068ab2aba` (13 October) is clean. The overlap bot lists #5119 for `docs/dev/debt/libSceAudioOut.md` L18, the debt file this change also touches; whichever lands second needs a small rebase there. - No title run; ASTRO BOT and ASTRO's PLAYROOM are not available here. Linux not tested. Ports of other types (pad routes) are not covered by the test; `output` stays main for them, as before. A search of open PRs for `sceAudioOut2PortGetState` found only this one. ### 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 in TechnicalDebt - [x] No notes, investigation `.md` files or images added to the repository - [x] New third-party code is a submodule built from source (none added) - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Unblocks: none - [x] AI-assisted: yes AI-assisted (Claude Code). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
nicolasfalesy commented 2026-10-13 06:10:53 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by nicolasfalesy on 2026-10-13T06:10:53Z.


Linux test (Arch, GCC 16.2.1, Release, PipeWire), this PR merged onto main 7e181fcc3 (clean merge): all 10 audio_out* tests pass, including audio_out2_device_state. With AudioOut2Port.cpp put back to main's version, audio_out2_device_state fails on Linux too, so the new check guards the change on both systems. No title run.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6139447711 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4778#issuecomment-6139447711). Originally posted by [nicolasfalesy](https://github.com/nicolasfalesy) on 2026-10-13T06:10:53Z. --- Linux test (Arch, GCC 16.2.1, Release, PipeWire), this PR merged onto `main` 7e181fcc3 (clean merge): all 10 `audio_out*` tests pass, including `audio_out2_device_state`. With `AudioOut2Port.cpp` put back to `main`'s version, `audio_out2_device_state` fails on Linux too, so the new check guards the change on both systems. No title run.
coltken95 commented 2026-10-13 11:11:25 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by coltken95 on 2026-10-13T11:11:25Z.


Linux validation (Ubuntu 24.04, GCC 13.3, Release), this PR's commit on main at 77b9f7270: audio_out2_device_state passes. With main's sources and this PR's test it aborts, so the test catches the reported channel count.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6144249759 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4778#issuecomment-6144249759). Originally posted by [coltken95](https://github.com/coltken95) on 2026-10-13T11:11:25Z. --- Linux validation (Ubuntu 24.04, GCC 13.3, Release), this PR's commit on `main` at 77b9f7270: `audio_out2_device_state` passes. With `main`'s sources and this PR's test it aborts, so the test catches the reported channel count. AI-assisted: yes
xXPBSXx commented 2026-10-13 21:18:35 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-13T21:18:35Z.


Thank you for the Linux validations, @nicolasfalesy and @coltken95. Noted for the record: the overlap bot lists #5119 for docs/dev/debt/libSceAudioOut.md L18; whichever PR lands second needs a small rebase there. No change to the code.

AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6155401383 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4778#issuecomment-6155401383). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-13T21:18:35Z. --- Thank you for the Linux validations, @nicolasfalesy and @coltken95. Noted for the record: the overlap bot lists #5119 for `docs/dev/debt/libSceAudioOut.md` L18; whichever PR lands second needs a small rebase there. No change to the code. AI-assisted (Claude Code).
adriadam10 commented 2026-10-14 17:08:20 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-14T17:08:20Z.


Checked on this PR merged onto main: build and ctest of libSceAudioOut (12/12) pass, and audio_out2_device_state fails with AudioOut2Port.cpp reverted. Linux runs from @nicolasfalesy and @coltken95 agree. The channel count follows another emulator only, which the debt entry records; merging.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6173912078 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4778#issuecomment-6173912078). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-14T17:08:20Z. --- Checked on this PR merged onto main: build and ctest of libSceAudioOut (12/12) pass, and `audio_out2_device_state` fails with `AudioOut2Port.cpp` reverted. Linux runs from @nicolasfalesy and @coltken95 agree. The channel count follows another emulator only, which the debt entry records; merging.
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!4778
No description provided.