Skip to content

feat(audioin): implement sceAudioInHqOpen - #570

Closed
Phi1ow wants to merge 2 commits into
boykopovar:mainfrom
Phi1ow:implement-audioin-hqopen
Closed

Phi1ow wants to merge 2 commits into
boykopovar:mainfrom
Phi1ow:implement-audioin-hqopen

Conversation

@Phi1ow

@Phi1ow Phi1ow commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

What

sceAudioInHqOpen was a throwing stub. It takes the same parameters as sceAudioInOpen and
opens an input port in the same way; the "Hq" variant only differs by the high-quality formats it
accepts, which sceAudioInOpen already validates. It now forwards to sceAudioInOpen, as it does
in shadPS4.

Tested

Extends the existing guest_audio_in validation with two sceAudioInHqOpen calls (invalid type
and invalid size) that go through the shared validation path.

Built with MinGW-w64 GCC 15.2.0 (the CI toolchain) on Windows 11; ctest -R guest_audio_in passes
(both guest_audio_in_capture and guest_audio_in_no_device). On main the stub throws not implemented, so the test aborts without the change.

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 (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
  • AI-assisted: yes

@github-actions github-actions Bot added the prx label Oct 4, 2026
@oneandonlydean

Copy link
Copy Markdown
Collaborator

Thanks. The NID recomputes (nya-R5gDYhM is sceAudioInHqOpen), and the two new rows go through the shared validation as described. One thing before it goes in: the claim that the HQ port differs from sceAudioInOpen only in the formats it accepts comes from shadPS4, which forwards it unchanged, but the other emulator sources don't agree. BryKytyPS5 (a KytyPS5 fork, src/libs/audio.cpp, OpenPort(..., asynchronous = true)) treats the HQ port differently in two ways:

  1. It only accepts len == 128 and freq == 48000. A length of 256 returns INVALID_SIZE and 16000 Hz returns INVALID_FREQ, while forwarding accepts both.
  2. Input on an HQ port doesn't block for a full block. It waits one grain and then returns whatever has been captured (up to 384 frames), where sceAudioInOpen's port waits until it has len frames.

Neither source is the console, so I can't say which is right. Under the exact-or-throw rule, I'd accept only what both agree on (type 0 or 1, index 0, 128 samples at 48000 Hz, the same params), throw for 256 samples and 16000 Hz on the HQ path, and add a line under "Unknown function info" in docs/dev/TechnicalDebt.md saying that an HQ port captures with the same blocking cadence as sceAudioInOpen and that the real cadence is unknown. A test row with 256 samples (expecting the throw) would then cover the difference.

Small one: a param of 0x10 now reaches sceAudioInOpen's NotImplemented_nid_no_patch(__func__), so the message names sceAudioInOpen instead of sceAudioInHqOpen.

For context, PPSA21564 imports sceAudioInHqOpen, but it hasn't been called in my runs (on main it throws), so this doesn't change anything I can observe yet.

@oneandonlydean

Copy link
Copy Markdown
Collaborator

Are you still working on this? The points from 10-04 are still open:

  • accept only what shadPS4 and KytyPS5 agree on for the HQ port, and throw for 256 samples and 16000 Hz;
  • add an "Unknown function info" line for the capture cadence;
  • make the error name sceAudioInHqOpen rather than sceAudioInOpen.

PPSA21564 imports sceAudioInHqOpen, so it's worth finishing.

Phi1ow added 2 commits October 6, 2026 23:47
sceAudioInHqOpen was a throwing stub. It takes the same parameters as sceAudioInOpen and opens
an input port the same way; the "Hq" variant only differs by the high-quality formats it accepts,
which sceAudioInOpen already validates. It now forwards to sceAudioInOpen, as it does in shadPS4.

Extends the existing guest_audio_in validation with two sceAudioInHqOpen calls (invalid type and
size) that go through the shared validation. It fails on main (the stub throws) and passes with
the change.
Per review: sceAudioInHqOpen now throws for 256 samples and 16000 Hz, where shadPS4 (which
forwards to sceAudioInOpen) and KytyPS5 (which accepts only 128 samples at 48000 Hz) disagree,
and forwards the agreed 128/48000 format to sceAudioInOpen. A thrown report now names
sceAudioInHqOpen. Records the unknown capture cadence in docs/dev/TechnicalDebt.md and updates
the guest_audio_in rows to a valid HQ length.
@Phi1ow
Phi1ow force-pushed the implement-audioin-hqopen branch from 38545f3 to 703249d Compare October 6, 2026 21:48
@github-actions github-actions Bot added the docs label Oct 6, 2026
@Phi1ow

Phi1ow commented Oct 6, 2026

Copy link
Copy Markdown
Contributor Author

Done. sceAudioInHqOpen now throws (reporting its own name) for the 256-sample length and 16000 Hz that shadPS4 and KytyPS5 disagree on, and forwards the agreed 128/48000 format to sceAudioInOpen. Added an "Unknown function info" line for the capture cadence, and the guest_audio_in rows use a valid HQ length now. guest_audio_in passes here.

@oneandonlydean

Copy link
Copy Markdown
Collaborator

Thanks for finishing all three points; it passed our regression runs too.

One question remains, the same as on #571 and #572: which title calls sceAudioInHqOpen? The owner has asked us to merge only changes a title needs. If you know one, please name it with the log line where it stops on main, and it can go in. If not, we'd rather close it for now and reopen it once a title reaches it.

@adriadam10 adriadam10 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked the code against the references: KytyPS5 AudioInHqOpen goes through OpenPort(..., true), shadPS4 forwards to sceAudioInOpen, and SharpProspero documents the HQ port as 48 kHz / 128-sample grain. sceAudioInOpen only accepts len 128/256 and freq 48000/16000, so the 128/48000 pair is the only one that reaches an open port and the throw for 256 / 16000 is consistent with Dean's earlier request. Two things left:

  • core/libs/tests/GuestAudioIn.cpp:44-45: the new rows only cover the error paths (type 2, len 512). Nothing opens an HQ port, so the forwarding itself is untested. Please add a success row (sceAudioInHqOpen(user, 0, 0, 128, 48000, 2) > 0, then sceAudioInInput returns 128 and sceAudioInClose returns 0), e.g. in TestNoDevice, and ideally one case per throw (256 samples, 16000 Hz) if the guest test harness can catch it.
  • The PR description still says it only forwards to sceAudioInOpen; please update it with the 128/48000 restriction.

On Dean's question about the title: sceAudioInHqOpen is in the import list of Astro's Playroom (PPSA01325) as an unimplemented stub, and Dean noted PPSA21564 imports it too. If you have a log line of where either stops on main, add it to the description.

@EdouardSence

Copy link
Copy Markdown
Contributor

On which title calls it: Astro Bot (PPSA21567 v01.019.000, retail) calls sceAudioInHqOpen from its microphone setup. The call site in the converted eboot.bin (AnyPS5 app.elf, code at vaddr 0) chooses between the two opens on a per-object flag:

1011a6a  cmp    BYTE PTR [r14+0xec],0x0
1011a72  mov    edi,DWORD PTR [r14+0x8]      ; userId
1011a76  je     1011adb
1011a78  mov    esi,0x1                      ; type 1
1011a7d  mov    ecx,0x80                     ; 128 samples
1011a82  mov    r8d,0xbb80                   ; 48000 Hz
1011a88  mov    r9d,0x2                      ; param 2
1011a8e  xor    edx,edx                      ; index 0
1011a90  call   sceAudioInHqOpen
...
1011adb  mov    ecx,0x100                    ; 256 samples
1011ae0  mov    r8d,0x3e80                   ; 16000 Hz
1011ae6  mov    r9d,0x1                      ; param 1
1011af2  xor    esi,esi                      ; type 0
1011af4  xor    edx,edx                      ; index 0
1011af6  call   sceAudioInOpen

The HQ call is (userId, 1, 0, 128, 48000, 2), which is the format this PR forwards. These are the only two AudioIn open call sites in the executable. The title's sce_module modules import neither function.

What I can't give is a stop on main. In my runs, scripted input from boot through the intro cutscene never reached this code (I logged both entry points), and Astro Bot also needs #759 to boot on current main. So this is a static call site, not a runtime log line.

Found and written by Claude (AI assistant) on a contributor's machine.

@oneandonlydean

Copy link
Copy Markdown
Collaborator

Closing for now: the points from 2026-10-07 are still open. If you pick it back up, please comment here and it can be reopened.

@fma-rc

fma-rc commented Oct 11, 2026

Copy link
Copy Markdown
Contributor

A title reaches this on main now: Astro's Playroom (PPSA01325). On main 7b5214d (Linux, RTX 5080) it loads, logs LoadLevelResources: opening and stops with

what():  sceAudioInHqOpen not implemented

With this PR's head 703249d merged onto that commit (it merges cleanly) the title gets past the call, loads pausemenu and timeattack_menu and stops later on an unrelated AGC error, sampling the depth plane of depth surface ... is not implemented. The two audio-in tests pass on the merged tree. One run each.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants