feat(audioin): implement sceAudioInHqOpen #570

Closed
Phi1ow wants to merge 2 commits from upstream-pr/570 into main
Phi1ow commented 2026-10-04 22:23:55 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Phi1ow on 2026-10-04T22:23:55Z.


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
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4738080696 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/570). Originally posted by [Phi1ow](https://github.com/Phi1ow) on 2026-10-04T22:23:55Z. --- ### 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 - [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](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [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] AI-assisted: yes
oneandonlydean commented 2026-10-04 23:43:58 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-04T23:43:58Z.


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.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:5985702340 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/570#issuecomment-5985702340). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-04T23:43:58Z. --- 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 commented 2026-10-06 21:20:49 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-06T21:20:49Z.


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.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6025674419 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/570#issuecomment-6025674419). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-06T21:20:49Z. --- 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 commented 2026-10-06 21:52:20 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Phi1ow on 2026-10-06T21:52:20Z.


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.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6026126769 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/570#issuecomment-6026126769). Originally posted by [Phi1ow](https://github.com/Phi1ow) on 2026-10-06T21:52:20Z. --- 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 commented 2026-10-07 03:45:45 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-07T03:45:45Z.


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.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6030479466 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/570#issuecomment-6030479466). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-07T03:45:45Z. --- 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 commented 2026-10-07 15:54:29 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-07T15:54:29Z.

Review: CHANGES_REQUESTED


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.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5444864226 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/570#pullrequestreview-5444864226). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-07T15:54:29Z. **Review:** CHANGES_REQUESTED --- 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 commented 2026-10-08 13:55:43 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by EdouardSence on 2026-10-08T13:55:43Z.


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.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6061446372 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/570#issuecomment-6061446372). Originally posted by [EdouardSence](https://github.com/EdouardSence) on 2026-10-08T13:55:43Z. --- 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 commented 2026-10-10 18:08:15 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-10T18:08:15Z.


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.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6100603490 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/570#issuecomment-6100603490). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-10T18:08:15Z. --- 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 commented 2026-10-11 08:31:22 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by fma-rc on 2026-10-11T08:31:22Z.


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

what():  sceAudioInHqOpen not implemented

With this PR's head 703249dc 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.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6107154772 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/570#issuecomment-6107154772). Originally posted by [fma-rc](https://github.com/fma-rc) on 2026-10-11T08:31:22Z. --- A title reaches this on `main` now: Astro's Playroom (PPSA01325). On `main` 7b5214d4 (Linux, RTX 5080) it loads, logs `LoadLevelResources: opening` and stops with ``` what(): sceAudioInHqOpen not implemented ``` With this PR's head 703249dc 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.

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