feat(libSceAudiodec.native): implement native decoder creation, clearing, termination, and decode variants #28599
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/28599"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by cmsierrave-coder on 2026-12-01T23:23:04Z.
What
The follow-up bounds the Decode2 input copy at 1 MiB and rechecks decoder identity after copying. Native decoder creation and deletion are serialized with termination. An active AudioDec context is required to create a decoder, and termination propagates rwlock destruction failures while retaining cleanup state for a retry.
Implement
sceAudiodecTerminate,sceAudiodecCreateDecoderEx,sceAudiodecClearContextEx, and the seven native decode variants (Decode2,Decode2Ex,Decode2WithPriority,Decode2WithPriorityEx,DecodeEx,DecodeWithPriority,DecodeWithPriorityEx) inlibSceAudiodec.native:sceAudiodecCreateDecoderExfor ATRAC9 (1), MP3 (2), and M4AAC (3) ontolibSceAjm.nativeinstances backed bylibSceAudiodec's FFmpeg/LibAtrac9 decoders, while keeping unverified codec types (4,6,10,11,12) throwing viaNotImplemented_nid_no_patch(__func__).sceAudiodecClearContextEx,sceAudiodecDeleteDecoderExdecoder cleanup,sceAudiodecTerminate(rwlock destroy + AJM/AJMI finalize), and all seven decode variants while preserving every firmware 13.42 argument check and guest-copy guard.GuestAudiodecNative.cppand document scope indocs/dev/debt/changes/feat-audiodec-native.md.Tested
Current head
9f391074bbpassed the conventions, debt-fold and whitespace checks. CircleCI passed guest_audiodec_native on Linux, including the unreadable input, oversized input, wrong-owner deletion and retired-context cases. The runner used memory comparison because userfaultfd write watch was unavailable. The fork's Windows workflow dispatch returned HTTP 422 because Actions is disabled for the repository.Earlier Windows results
Windows (WinLibs GCC 15.2.0 / Ninja): built
libSceAudiodec.nativeand its test executables; ranctest --test-dir build -R "^(guest_audiodec|guest_audiodec_native|guest_audiodec_ajm_context|guest_audiodec_ajm_context_pointer)$" --output-on-failure(4/4 passed),python tools/debt_fold.py --check, andpython tools/check_conventions.py --base origin/main.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Summary by CodeRabbit
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-12-01T23:34:08Z.
Review: COMMENTED
🏛️ Architecture findings (4)
Advisory architecture findings (4)
💬 Code review
Actionable comments posted (2)
9ba83808-f2e0-4094-95d4-8d8d1a818af3Reviewing files that changed from the base of the PR and between
7d3d015feeandb23338bf9a.core/libs/prx/libSceAudiodec.native/Export.cppcore/libs/tests/GuestAudiodecNative.cppdocs/dev/debt/changes/feat-audiodec-native.mdIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-12-02T00:32:21Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
Changes are required before merge:
sceAudiodecTerminatemust destroy tracked AJM instances before discarding their handles.What I ran
Reviewed head
b23338bf9a2973cbbf114feeec65ec15a1580ffausing the prepared diff and pinned reader. No tests or builds were run; the Windows checks in the PR description are author-reported.Results
Negative control
Not run; no test was run.
Findings
Blocking
sceAudiodecTerminateremoves matching entries fromg_instancesbut does not callsceAjmInstanceDestroyfor their handles (core/libs/prx/libSceAudiodec.native/Export.cpp:668). The AJM service keeps instances in its global table until explicitly destroyed, and its currentsceAjmFinalizeis a no-op. Terminating a context with an undeleted decoder therefore drops the native decoder but leaves the AJM instance allocated. Destroy each tracked instance owned by this context before erasing it, and add a regression test that terminates with a live decoder. Changed code · AJM instance storage and destruction · AJM finalizeNon-blocking
None.
Sources
Read
core/libs/prx/libSceAudiodec.native/Export.cpp, the changed sections ofcore/libs/tests/GuestAudiodecNative.cpp, anddocs/dev/debt/changes/feat-audiodec-native.md. Also inspected codec behavior incore/libs/prx/libSceAudiodec/src/Codecs.cppand AJM instance lifecycle incore/libs/prx/libSceAjm.native/src/Ajm.cpp. The manifest lists all three changed files as reviewed and none as excluded.Not verified
No tests, builds, console behavior, or hardware behavior were verified in this review. The test results in the PR description are author-reported.
To get this to a good state
Destroy every tracked AJM instance belonging to the terminating context before erasing its local decoder, and add a regression test for termination with a live decoder. Rerun the reported four targeted tests and the listed debt and conventions checks on the updated head.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-12-02T01:53:36Z.
Review: COMMENTED
Actionable comments
92c6c13c-9a40-40cb-bf7e-5c28e2f2afa2Reviewing files that changed from the base of the PR and between
b23338bf9aandad5f03ddef.core/libs/prx/libSceAudiodec.native/Export.cppcore/libs/tests/GuestAudiodecNative.cppIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-12-02T03:27:40Z.
Review: COMMENTED
Reviewed — no blocking findings
The prepared diff and all three changed files were inspected, but the pinned repository reader could not provide source context because it tried to write its call log in the read-only run folder.
What I ran
Inspected PR head
ad5f03ddef0e04335796270e82cc17fa5823e3a2using the prepared review materials. Attempted a targeted search withrepo_read.py; it could not complete. No tests or build checks were run.Results
Findings
Blocking
None in the inspected changes.
Non-blocking
None.
Not verified
The repository call chains and decoder implementation context could not be checked with
repo_read.py. No tests or builds were performed. The preparedfiles.jsonlists three reviewed files and no excluded files; the inspected files werecore/libs/prx/libSceAudiodec.native/Export.cpp,core/libs/tests/GuestAudiodecNative.cpp, anddocs/dev/debt/changes/feat-audiodec-native.md.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-12-02T19:25:25Z.
Review: COMMENTED
Actionable comments
core/libs/tests/GuestAudiodecNative.cpp, lines418· 📐 Maintainability & Code Quality · ⚡ Quick winpcmOutstill contains the complete reference PCM.recreateDecoder()resets the decoder and sizes, but not those samples. If a regression reports the correct sizes but omits some writes, the finalmemcmpcan compare unchanged reference bytes. Use a separate buffer, or poisonpcmOutbefore the capacity-limited decode. This strengthens the regression test without changing decoder behavior. (raw.githubusercontent.com)b0e0a4d3-40ce-4d04-a7ed-0d311f802e16Reviewing files that changed from the base of the PR and between
ad5f03ddefand414a78bc1b.core/libs/prx/libSceAudiodec.native/Export.cppcore/libs/tests/GuestAudiodecNative.cppdocs/dev/debt/changes/feat-audiodec-native.mdIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-12-02T20:08:35Z.
Review: COMMENTED
Actionable comments
b7257485-963d-457d-9b80-64a6ab1e6a23Reviewing files that changed from the base of the PR and between
414a78bc1bandde30ea6312.core/libs/tests/GuestAudiodecNative.cppIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-12-02T20:57:02Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
Changes are required before merge: clean up the AJM instance if decoder construction fails.
What I ran
Reviewed head
de30ea63128c3642f8dfe7663c32fa11dbf09f07against basemain; no merged-preview check was run. I inspected the prepared description, commits, diff, manifest, and all three reviewed files, plus pinned source context withrepo_read.py. No build or tests were run. The author reports four audiodec CTest targets passing on Windows; that result was not independently verified.Results
Negative control
Could not run a negative control because no tests were run.
Findings
Blocking
core/libs/prx/libSceAudiodec.native/Export.cpp:524-546: The code creates an AJM instance before calling the decoder factories. IfCreateAt9,CreateMp3, orCreateAacInstancethrows during decoder construction, control exits without destroying that AJM instance. Make construction exception-safe so factory failures release the handle before propagating or returning an error.Non-blocking
None.
Sources
Not verified
No build, tests, negative control, or PS5 firmware behavior was checked. The author's reported Windows test run was not independently verified. All three files in
files.jsonunderreviewedwere inspected;files.jsonlists no excluded files.To get this to a good state
Make decoder creation exception-safe so a failed factory releases the AJM instance. On the new head, rerun the reported
guest_audiodec,guest_audiodec_native,guest_audiodec_ajm_context, andguest_audiodec_ajm_context_pointerCTest targets.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-12-02T21:56:37Z.
Review: COMMENTED
Reviewed — comments
Nothing blocks this; the points below are optional. The review is incomplete because I could not read the full changed source at the pinned head.
What I ran
Reviewed head
73a4fb6b0c1bf21fb26a53b5e9305dda93302747. I read the prepared description, commits, manifest, diff, and files list. I reviewed the test changes and documentation from the diff. The reader returned lines 1–190 ofExport.cpp, then failed while trying to log the read because the run folder is read-only. I did not run tests or builds; the PR description reports author-run checks.Commands attempted:
Results
Negative control
Not run; no tests were run in this review.
Findings
Blocking
None established from the material inspected.
Non-blocking
None.
Sources
The prepared diff contains changes to
core/libs/prx/libSceAudiodec.native/Export.cpp,core/libs/tests/GuestAudiodecNative.cpp, anddocs/dev/debt/changes/feat-audiodec-native.md. The manifest lists all three as reviewed and no files as excluded by rule. The full test file was available underfiles/; I inspected its changed test hunks in the diff. The fullExport.cppand debt document were not available underfiles/.Not verified
I could not review the full
Export.cppat the pinned head or confirm its interactions with existing callers. The debt document was inspected through the diff only. I did not independently verify the author-reported Windows build, tests, debt check, or conventions check. No files were excluded by the stated file rules.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-12-02T22:00:41Z.
Review: COMMENTED
Actionable comments
1ebb9709-0a69-4540-ba56-ff4898dd3946Reviewing files that changed from the base of the PR and between
de30ea6312and73a4fb6b0c.core/libs/prx/libSceAudiodec.native/Export.cppIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T03:58:17Z.
Review: COMMENTED
The
GuestAudiodecNativeruntime assertions passed on Linux with this head's native Audiodec, AJM, and AJMI sources and the pinned FFmpeg and ATRAC9 dependencies. That includes context and decoder release checks, clear/reset, and the AAC retry regression.I repeated the AAC comparison with five output capacities from 4,096 to 16,384 bytes. Those cases needed two to five calls each. All consumed the same 624 ADTS bytes and produced the same 20,480 PCM bytes as the single-call reference, with a byte-for-byte match. The fixture used direct linkage, so shared-module export lookup was outside this run.
AI-assisted: yes.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-12-04T04:22:25Z.
Review: COMMENTED
Actionable comments
e4553cfa-4427-473f-b18f-3ed65e866b03Reviewing files that changed from the base of the PR and between
73a4fb6b0cand9f391074bb.core/libs/prx/libSceAudiodec.native/Export.cppcore/libs/tests/GuestAudiodecNative.cppdocs/dev/debt/changes/feat-audiodec-native.mdIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-12-04T04:55:00Z.
Review: COMMENTED
Reviewed — no blocking findings
The reviewed changes have no verified blocking defects; adding an ATRAC9 end-to-end test would strengthen coverage before treating all three codec paths as verified.
What I ran
Reviewed head
9f391074bbc29751e19364f68647f7011ad1e720using the prepared full snapshots for all three reviewed files. No tests or build checks were run.repo_read.pycould not complete because it could not write its read log in the read-only workspace.Results
Negative control
Not run; no tests were run.
Findings
Blocking
None.
Non-blocking
core/libs/prx/libSceAudiodec.native/Export.cpp:570and the AAC/MP3 cases incore/libs/tests/GuestAudiodecNative.cpp:357and:461.Sources
Not verified
core/libs/prx/libSceAudiodec.native/Export.cpp,core/libs/tests/GuestAudiodecNative.cpp, anddocs/dev/debt/changes/feat-audiodec-native.md. Excluded: none.To get this to a good state
Nothing is required.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.