feat(libSceAudiodec.native): read the Ajm ids with sceAudiodecGetAjmContext #13719

Merged
zaryabzip merged 2 commits from upstream-pr/13719 into main 2026-10-31 21:05:07 +00:00
zaryabzip commented 2026-10-31 02:32:34 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by zaryabzip on 2026-10-31T02:32:34Z.


What

sceAudiodecGetAjmContext(const void* context, uint32_t* ajmi, uint32_t* ajm) gets a body. It follows @BunnyFl's firmware 13.42 run of libSceAudiodec.native.sprx, done under an emulator with imports stubbed, not on a console:

  • A null context returns 0x807F0002 and writes nothing.
  • Otherwise the 32-bit id at offset 0 of the context goes to *ajmi and the one at offset 4 to *ajm, each only when its output isn't null, and the call returns 0.
  • There's no lock and no service call. It doesn't check that sceAudiodecInitialize filled the context: after sceAudiodecTerminate it returns the old values.

So the call is a plain read, and it's exact for any context, including ones this project's sceAudiodecInitialize (still a stub) never filled.

On the console only libSceAudiodec.native exports this call and sceAudiodecUnregisterCodec; libSceAudiodec exports neither. Both used to sit in libSceAudiodec/Export.cpp, which is built into both libraries, so they move into libSceAudiodec.native/Export.cpp (second commit, after review). sceAudiodecUnregisterCodec keeps throwing: the same run settles its arguments and local checks, but every accepted type ends in an Ajm service call whose result it returns. Both debt entries move to libSceAudiodec.native.md and record what the run found. libSceAudiodec.native goes from 0 to 1 of 16. libSceAudiodec loses the two exports and is now 6 of 6.

Two tests:

  • GuestAudiodecAjmContext.cpp, linked to libSceAudiodec.native, covers a null context (both outputs left untouched), the two ids read from offsets 0 and 4, each null output skipped, and the context left unchanged. It resolves the export at runtime through a function type that matches the new declaration, so it builds on main and aborts there at the first call.
  • GuestAudiodecStandardExports.cpp, linked to libSceAudiodec, checks that the library is loaded and exports sceAudiodecInitLibrary, but exports neither moved call. On main it fails at sceAudiodecGetAjmContext.

Tested

Windows 11 (WinLibs MinGW-w64 GCC 15.2.0 UCRT r7, CMake 4.3.1, Ninja 1.13.2) and Ubuntu 24.04 on WSL2 (GCC 13.3.0, CMake 3.28.3, Ninja 1.11.1), both with the head 91999d11d5 merged into main 0cc02f7cde.

  • No warnings. Both Export.cpp files, every includer of both include/Api.hpp headers, and each header compiled on its own build with no warnings.
  • ctest -R guest_audiodec: guest_audiodec, guest_audiodec_ajm_context and guest_audiodec_standard_exports pass on both hosts, each 3 of 3 on --repeat until-fail:3.
  • Exports (objdump -p on Windows, nm -D on Linux, patched and unpatched): libSceAudiodec.prx has neither sceAudiodecGetAjmContext (GkEWCZ1JH-k) nor sceAudiodecUnregisterCodec (BwHzGZkW0Y4), and libSceAudiodec.native.prx has both.
  • Baselines on that main with only the new test files and their CMakeLists.txt blocks:
    • guest_audiodec_ajm_context builds and then aborts with sceAudiodecGetAjmContext not implemented on both hosts.
    • guest_audiodec_standard_exports builds and then fails with sceAudiodecGetAjmContext is exported by libSceAudiodec on both hosts.
  • tools/check_conventions.py passes, and tools/pr_overlap.py reported no overlap for the first commit.

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: none
  • GPUs tested: n/a
  • AI-assisted: yes (Claude Code)
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5093683391 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/13719). Originally posted by [zaryabzip](https://github.com/zaryabzip) on 2026-10-31T02:32:34Z. --- ### What `sceAudiodecGetAjmContext(const void* context, uint32_t* ajmi, uint32_t* ajm)` gets a body. It follows @BunnyFl's [firmware 13.42 run](https://github.com/boykopovar/AnyPS5/issues/13680#issuecomment-6537745276) of `libSceAudiodec.native.sprx`, done under an emulator with imports stubbed, not on a console: - A null context returns `0x807F0002` and writes nothing. - Otherwise the 32-bit id at offset 0 of the context goes to `*ajmi` and the one at offset 4 to `*ajm`, each only when its output isn't null, and the call returns 0. - There's no lock and no service call. It doesn't check that `sceAudiodecInitialize` filled the context: after `sceAudiodecTerminate` it returns the old values. So the call is a plain read, and it's exact for any context, including ones this project's `sceAudiodecInitialize` (still a stub) never filled. On the console only `libSceAudiodec.native` exports this call and `sceAudiodecUnregisterCodec`; `libSceAudiodec` exports neither. Both used to sit in `libSceAudiodec/Export.cpp`, which is built into both libraries, so they move into `libSceAudiodec.native/Export.cpp` (second commit, after review). `sceAudiodecUnregisterCodec` keeps throwing: the same run settles its arguments and local checks, but every accepted type ends in an Ajm service call whose result it returns. Both debt entries move to `libSceAudiodec.native.md` and record what the run found. libSceAudiodec.native goes from 0 to 1 of 16. libSceAudiodec loses the two exports and is now 6 of 6. Two tests: - `GuestAudiodecAjmContext.cpp`, linked to `libSceAudiodec.native`, covers a null context (both outputs left untouched), the two ids read from offsets 0 and 4, each null output skipped, and the context left unchanged. It resolves the export at runtime through a function type that matches the new declaration, so it builds on `main` and aborts there at the first call. - `GuestAudiodecStandardExports.cpp`, linked to `libSceAudiodec`, checks that the library is loaded and exports `sceAudiodecInitLibrary`, but exports neither moved call. On `main` it fails at `sceAudiodecGetAjmContext`. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> Windows 11 (WinLibs MinGW-w64 GCC 15.2.0 UCRT r7, CMake 4.3.1, Ninja 1.13.2) and Ubuntu 24.04 on WSL2 (GCC 13.3.0, CMake 3.28.3, Ninja 1.11.1), both with the head 91999d11d5 merged into `main` 0cc02f7cde. - No warnings. Both `Export.cpp` files, every includer of both `include/Api.hpp` headers, and each header compiled on its own build with no warnings. - `ctest -R guest_audiodec`: `guest_audiodec`, `guest_audiodec_ajm_context` and `guest_audiodec_standard_exports` pass on both hosts, each 3 of 3 on `--repeat until-fail:3`. - Exports (`objdump -p` on Windows, `nm -D` on Linux, patched and unpatched): `libSceAudiodec.prx` has neither `sceAudiodecGetAjmContext` (`GkEWCZ1JH-k`) nor `sceAudiodecUnregisterCodec` (`BwHzGZkW0Y4`), and `libSceAudiodec.native.prx` has both. - Baselines on that `main` with only the new test files and their `CMakeLists.txt` blocks: - `guest_audiodec_ajm_context` builds and then aborts with `sceAudiodecGetAjmContext not implemented` on both hosts. - `guest_audiodec_standard_exports` builds and then fails with `sceAudiodecGetAjmContext is exported by libSceAudiodec` on both hosts. - `tools/check_conventions.py` passes, and `tools/pr_overlap.py` reported no overlap for the first commit. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [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 under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/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: <!-- #PR, or none --> none - [x] Fixes: <!-- issue it closes as Fixes #N, or none --> none - [x] Unblocks: <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> none - [x] GPUs tested: <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> n/a - [x] AI-assisted: <!-- yes / no --> yes (Claude Code)
MarcZX10 commented 2026-10-31 02:36:02 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-31T02:36:02Z.

Review: CHANGES_REQUESTED


Reviewed — changes requested

The implementation returns success from the standard libSceAudiodec target even though the PR's firmware report says this export exists only in libSceAudiodec.native.

What I ran

Reviewed head 8f941d036405ffeb2733456f20c765abc3b40e07, based on main 0cc02f7cde69941f651819b1f7a80f7aa722a08b; the exact-head merge preview was clean. Environment: Linux 6.1.0-54-amd64, Python 3.11.2, GCC 12.2.0. No local compilation or C++ tests were run.

python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 13719
git diff 0cc02f7cde69941f651819b1f7a80f7aa722a08b...8f941d036405ffeb2733456f20c765abc3b40e07 --check
python3 tools/pr_abi_audit.py --base 0cc02f7cde69941f651819b1f7a80f7aa722a08b --head 8f941d036405ffeb2733456f20c765abc3b40e07
python3 tools/pr_test_quality.py --root /tmp/anyps5-pr-precheck/boykopovar-AnyPS5-pr-13719-8f941d036405/head-8f941d036405-1732f2f5 --json core/libs/prx/libSceAudiodec/CMakeLists.txt core/libs/prx/libSceAudiodec/Export.cpp core/libs/prx/libSceAudiodec/include/Api.hpp core/libs/tests/GuestAudiodecAjmContext.cpp docs/dev/debt/libSceAudiodec.md
gh pr checks 13719 --repo boykopovar/AnyPS5

Results

Check Result
Diff and conventions Passed on the exact head.
Aggregate no-build precheck Diff, conventions, and merge preview passed. The isolated PR snapshot lacks the workspace-only ABI and test-quality helper scripts; I reran both from the workspace. The precheck report says head and base remained unchanged.
ABI audit Passed with no lexical findings; this does not determine which PRX should export the symbol.
Test registration Heuristic warned that the C++ test may be unregistered; manual inspection confirmed add_test_executable and add_test(NAME guest_audiodec_ajm_context ...) in the changed CMake file.
Merge preview Clean against current main; no declared dependencies.
Hosted CI Final snapshot: report, intake, eligibility, conventions, labels, and library-portability passed. windows was pending. Linux, relinker, ASAN, register-context, and write-watch jobs were skipped by workflow selection.
Author-reported tests The PR reports three passing runs each on Windows and Ubuntu/WSL2, and a baseline run that aborts on main; I did not reproduce these runs.
Unedited output from checks

git diff --check produced no output and exited 0. Convention check:

All conventions checks passed.

ABI audit:

ABI audit: passed
sceAudiodecClearContext: NID=6Vf9WTLDoss declarations=1 definitions=1 aliases=0
sceAudiodecCreateDecoder: NID=O3f1sLMWRvs declarations=1 definitions=1 aliases=0
sceAudiodecDecode: NID=KHXHMDLkILw declarations=1 definitions=1 aliases=0
sceAudiodecDeleteDecoder: NID=Tp+ZEy69mLk declarations=1 definitions=1 aliases=0
sceAudiodecGetAjmContext: NID=GkEWCZ1JH-k declarations=1 definitions=1 aliases=0
sceAudiodecInitLibrary: NID=VjhsmxpcezI declarations=1 definitions=1 aliases=0
sceAudiodecTermLibrary: NID=h5jSB2QIDV0 declarations=1 definitions=1 aliases=0
sceAudiodecUnregisterCodec: NID=BwHzGZkW0Y4 declarations=1 definitions=1 aliases=0
limit: This lexical audit does not parse C++ fully, prove calling-convention or binary ABI correctness, verify runtime version tables, or replace compilation.
limit: An absent source declaration or explicit alias can be intentional for assembly exports, conditional platform code, or generated interfaces; inspect findings before treating them as defects.

The test-quality heuristic's output:

{
  "findings": [
    {
      "path": "core/libs/tests/GuestAudiodecAjmContext.cpp",
      "line": 1,
      "kind": "possible-unregistered-cpp-test",
      "message": "Changed C++ test source path was not found literally in CMake files; inspect registration, generated source lists, and workflow coverage."
    }
  ],
  "negative_control_candidates": [],
  "limits": [
    "Heuristics can miss weak assertions and can flag valid tests; inspect every finding.",
    "A test that passes against base is not by itself proof that the PR test is inadequate.",
    "Negative controls are only candidates until the test actually runs against base and fails by assertion rather than import/setup error."
  ]
}

The aggregate precheck could not run those two workspace-only helper scripts inside its isolated PR checkout:

/usr/bin/python3: can't open file '/tmp/anyps5-pr-precheck/boykopovar-AnyPS5-pr-13719-8f941d036405/head-8f941d036405-1732f2f5/tools/pr_abi_audit.py': [Errno 2] No such file or directory
/usr/bin/python3: can't open file '/tmp/anyps5-pr-precheck/boykopovar-AnyPS5-pr-13719-8f941d036405/head-8f941d036405-1732f2f5/tools/pr_test_quality.py': [Errno 2] No such file or directory

Negative control

Assertion Change to code under test Result
The new test distinguishes this implementation from main Restore main's throwing stub The PR reports that the test aborts on both hosts; I did not independently run this control.

Findings

Blocking

The implementation is in core/libs/prx/libSceAudiodec/Export.cpp. The shared AudiodecLibrary.cmake compiles that file into both libSceAudiodec and libSceAudiodec.native; the native target also adds its separate native Export.cpp. The new test explicitly loads libSceAudiodec.prx, so it verifies that the standard library now returns success. However, the PR's firmware report and updated debt entry say this measured export exists only in libSceAudiodec.native.sprx. As written, the standard target returns successful behavior for a symbol the PR says the console does not export from that module.

Please keep the measured implementation in the native module only and test that native export. Also verify the standard module does not gain successful behavior for this symbol.

Non-blocking

The reported firmware observation was made under an emulator with imports stubbed, not on physical PS5 hardware. The PR identifies that limitation; I have not independently verified console behavior.

Sources

Not verified

No local compile, C++ test run, physical-console run, or independent firmware emulation. Windows CI was still running; the workflow skipped Linux and relinker-related jobs.

To get this to a good state

Move the implementation and its test to the native-only export path, preserve the standard module's console-appropriate behavior, and verify both module surfaces. I will rerun the same relevant checks on the new head.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5720610388 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/13719#pullrequestreview-5720610388). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-31T02:36:02Z. **Review:** CHANGES_REQUESTED --- # Reviewed — changes requested The implementation returns success from the standard `libSceAudiodec` target even though the PR's firmware report says this export exists only in `libSceAudiodec.native`. ## What I ran Reviewed head `8f941d036405ffeb2733456f20c765abc3b40e07`, based on `main` `0cc02f7cde69941f651819b1f7a80f7aa722a08b`; the exact-head merge preview was clean. Environment: Linux 6.1.0-54-amd64, Python 3.11.2, GCC 12.2.0. No local compilation or C++ tests were run. ```sh python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 13719 git diff 0cc02f7cde69941f651819b1f7a80f7aa722a08b...8f941d036405ffeb2733456f20c765abc3b40e07 --check python3 tools/pr_abi_audit.py --base 0cc02f7cde69941f651819b1f7a80f7aa722a08b --head 8f941d036405ffeb2733456f20c765abc3b40e07 python3 tools/pr_test_quality.py --root /tmp/anyps5-pr-precheck/boykopovar-AnyPS5-pr-13719-8f941d036405/head-8f941d036405-1732f2f5 --json core/libs/prx/libSceAudiodec/CMakeLists.txt core/libs/prx/libSceAudiodec/Export.cpp core/libs/prx/libSceAudiodec/include/Api.hpp core/libs/tests/GuestAudiodecAjmContext.cpp docs/dev/debt/libSceAudiodec.md gh pr checks 13719 --repo boykopovar/AnyPS5 ``` ## Results | Check | Result | |---|---| | Diff and conventions | Passed on the exact head. | | Aggregate no-build precheck | Diff, conventions, and merge preview passed. The isolated PR snapshot lacks the workspace-only ABI and test-quality helper scripts; I reran both from the workspace. The precheck report says head and base remained unchanged. | | ABI audit | Passed with no lexical findings; this does not determine which PRX should export the symbol. | | Test registration | Heuristic warned that the C++ test may be unregistered; manual inspection confirmed `add_test_executable` and `add_test(NAME guest_audiodec_ajm_context ...)` in the changed CMake file. | | Merge preview | Clean against current `main`; no declared dependencies. | | Hosted CI | Final snapshot: `report`, `intake`, `eligibility`, `conventions`, `labels`, and `library-portability` passed. `windows` was pending. Linux, relinker, ASAN, register-context, and write-watch jobs were skipped by workflow selection. | | Author-reported tests | The PR reports three passing runs each on Windows and Ubuntu/WSL2, and a baseline run that aborts on `main`; I did not reproduce these runs. | <details> <summary>Unedited output from checks</summary> `git diff --check` produced no output and exited 0. Convention check: ```text All conventions checks passed. ``` ABI audit: ```text ABI audit: passed sceAudiodecClearContext: NID=6Vf9WTLDoss declarations=1 definitions=1 aliases=0 sceAudiodecCreateDecoder: NID=O3f1sLMWRvs declarations=1 definitions=1 aliases=0 sceAudiodecDecode: NID=KHXHMDLkILw declarations=1 definitions=1 aliases=0 sceAudiodecDeleteDecoder: NID=Tp+ZEy69mLk declarations=1 definitions=1 aliases=0 sceAudiodecGetAjmContext: NID=GkEWCZ1JH-k declarations=1 definitions=1 aliases=0 sceAudiodecInitLibrary: NID=VjhsmxpcezI declarations=1 definitions=1 aliases=0 sceAudiodecTermLibrary: NID=h5jSB2QIDV0 declarations=1 definitions=1 aliases=0 sceAudiodecUnregisterCodec: NID=BwHzGZkW0Y4 declarations=1 definitions=1 aliases=0 limit: This lexical audit does not parse C++ fully, prove calling-convention or binary ABI correctness, verify runtime version tables, or replace compilation. limit: An absent source declaration or explicit alias can be intentional for assembly exports, conditional platform code, or generated interfaces; inspect findings before treating them as defects. ``` The test-quality heuristic's output: ```json { "findings": [ { "path": "core/libs/tests/GuestAudiodecAjmContext.cpp", "line": 1, "kind": "possible-unregistered-cpp-test", "message": "Changed C++ test source path was not found literally in CMake files; inspect registration, generated source lists, and workflow coverage." } ], "negative_control_candidates": [], "limits": [ "Heuristics can miss weak assertions and can flag valid tests; inspect every finding.", "A test that passes against base is not by itself proof that the PR test is inadequate.", "Negative controls are only candidates until the test actually runs against base and fails by assertion rather than import/setup error." ] } ``` The aggregate precheck could not run those two workspace-only helper scripts inside its isolated PR checkout: ```text /usr/bin/python3: can't open file '/tmp/anyps5-pr-precheck/boykopovar-AnyPS5-pr-13719-8f941d036405/head-8f941d036405-1732f2f5/tools/pr_abi_audit.py': [Errno 2] No such file or directory /usr/bin/python3: can't open file '/tmp/anyps5-pr-precheck/boykopovar-AnyPS5-pr-13719-8f941d036405/head-8f941d036405-1732f2f5/tools/pr_test_quality.py': [Errno 2] No such file or directory ``` </details> ## Negative control | Assertion | Change to code under test | Result | |---|---|---| | The new test distinguishes this implementation from `main` | Restore `main`'s throwing stub | The PR reports that the test aborts on both hosts; I did not independently run this control. | ## Findings ### Blocking The implementation is in `core/libs/prx/libSceAudiodec/Export.cpp`. The shared `AudiodecLibrary.cmake` compiles that file into both `libSceAudiodec` and `libSceAudiodec.native`; the native target also adds its separate native `Export.cpp`. The new test explicitly loads `libSceAudiodec.prx`, so it verifies that the standard library now returns success. However, the PR's firmware report and updated debt entry say this measured export exists only in `libSceAudiodec.native.sprx`. As written, the standard target returns successful behavior for a symbol the PR says the console does not export from that module. Please keep the measured implementation in the native module only and test that native export. Also verify the standard module does not gain successful behavior for this symbol. ### Non-blocking The reported firmware observation was made under an emulator with imports stubbed, not on physical PS5 hardware. The PR identifies that limitation; I have not independently verified console behavior. ## Sources - [Shared Audiodec target compiles `Export.cpp` for each target, at `main` `0cc02f7`](https://github.com/boykopovar/AnyPS5/blob/0cc02f7cde69941f651819b1f7a80f7aa722a08b/core/libs/prx/libSceAudiodec/AudiodecLibrary.cmake#L1-L5) - [Standard target declaration at `main` `0cc02f7`](https://github.com/boykopovar/AnyPS5/blob/0cc02f7cde69941f651819b1f7a80f7aa722a08b/core/libs/prx/libSceAudiodec/CMakeLists.txt#L1-L2) and [native target declaration](https://github.com/boykopovar/AnyPS5/blob/0cc02f7cde69941f651819b1f7a80f7aa722a08b/core/libs/prx/libSceAudiodec.native/CMakeLists.txt#L1-L3) - [Implementation at reviewed head `8f941d0`](https://github.com/boykopovar/AnyPS5/blob/8f941d036405ffeb2733456f20c765abc3b40e07/core/libs/prx/libSceAudiodec/Export.cpp#L180-L187) - [PR debt entry documenting the native-only firmware export](https://github.com/boykopovar/AnyPS5/blob/8f941d036405ffeb2733456f20c765abc3b40e07/docs/dev/debt/libSceAudiodec.md) - [Author-provided 13.42 emulator observation](https://github.com/boykopovar/AnyPS5/issues/13680#issuecomment-6537745276) ## Not verified No local compile, C++ test run, physical-console run, or independent firmware emulation. Windows CI was still running; the workflow skipped Linux and relinker-related jobs. ## To get this to a good state Move the implementation and its test to the native-only export path, preserve the standard module's console-appropriate behavior, and verify both module surfaces. I will rerun the same relevant checks on the new head.
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!13719
No description provided.