Capture PCM at set time when multiple AudioOut2 ports share a buffer #826
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
GPU
GUI
help wanted
question
Shaders
Video
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/KytyPS5--KytyPS5!826
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/826/head"
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?
@EmK530 on GitHub · 2026-09-25 14:10 UTC · original
EmK530:fix/criware-audio→main· +87 −21 · 2 files · 4 commits · merged 2026-09-25 22:19 UTCSummary
The CRIWARE audio engine renders multiple AudioOut2 ports in turn and passes the same scratch PCM buffer to
sceAudioOut2PortSetAttributesfor each port. Kyty previously retained the buffer pointer untilContextPush, after CRIWARE could already have overwritten it, causing silence in Neptunia ReVerse. The PS5 SDK AudioOut2 reference says the PCM buffer is copied bysceAudioOut2PortSetAttributesand may be freed when the call returns.Change
Each AudioOut2 port now owns a copy of its PCM bytes at
AudioOut2PortSetAttributestime. The queued output uses those bytes, kept alive through the synchronous backend submission. This replaces the earlier shared-pointer detection and snapshot fallback logic.Testing
audio_out2_port_testspasses, including a regression that reuses and overwrites one scratch buffer across two ports beforeContextPush.PPSA02721) launched with the checked-inlaunch.jsonarguments. The host output monitor captured nonzero PCM fromkyty_emulatorduring the run.Original PR demonstration: https://github.com/user-attachments/assets/ea8ae29b-2e95-4a99-a483-3cf73beaf1e2
AI usage
AI was involved in the process of debugging and zeroing in on the cause of this issue and implementing a fix. I have reviewed the changes in post, understood them and wrote this PR myself.
@coderabbitai[bot] on GitHub · 2026-09-25 14:17 UTC · original · edited 2026-09-25 22:29 UTC
Navigate logical layers of code changes, visualize relationships, and explore their blast radius.
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml
Review profile: CHILL
Plan: Advanced
Run ID:
fa5a60e5-06a1-4c27-abb5-271086072f88📥 Commits
Reviewing files that changed from the base of the PR and between
815a46f1eeand94494980ba.📒 Files selected for processing (1)
src/libs/libAudio2.cppIncluded review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
📝 Walkthrough
Walkthrough
Audio output ports now track whether their PCM snapshots are fresh. The code calculates PCM buffer size from the sample count, channel count, and data type. Setting PCM attributes clears the prior snapshot and captures PCM only when the pointer, audio handle, device, and calculated size meet the stated conditions. Queueing consumes the freshness flag and uses a snapshot only when it is fresh, the PCM pointer is shared, and the snapshot size is valid. Otherwise, it queues the current PCM pointer.
Suggested reviewers:
nmzikPriority: ⬇️ Low
Change: Bug fix
Merge Risk: ⚪ Minimal · up to
94494No actionable issue remains in the reviewed audio snapshot change; it is ready to merge after normal checks.
Security Architecture Review
Security architecture risk: 🔵 Low · up to
94494The change narrows when an existing PCM snapshot is used. The review found no new access path or weakened device check, but runtime isolation and caller-memory guarantees remain unverified.
Retained concerns
No architecture-level concerns identified.
Security review details
Security Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Comment
@coderabbitai helpto get the list of available commands.@coderabbitai[bot] on GitHub · 2026-09-25 14:17 UTC · original · edited 2026-09-25 15:16 UTC
On
src/libs/libAudio2.cppline 387 (outdated):🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Do not replay a snapshot on a later push.
If two ports retain the same PCM pointer, a second
AudioOut2ContextPushcan occur without anotherAudioOut2PortSetAttributescall. After the caller updates that buffer, this size check still selects the snapshots from the first push. The second push therefore outputs stale audio. Track whether each snapshot has already been submitted. When no new snapshot exists, use the current PCM pointer instead.✅ Addressed in commits
3700dabto9449498@coderabbitai[bot] on GitHub · 2026-09-25 14:17 UTC · original · reviewed
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml
Review profile: CHILL
Plan: Advanced
Run ID:
ec607b4c-b663-4bc8-a945-01a303a66df1📥 Commits
Reviewing files that changed from the base of the PR and between
7e1c2d1532and815a46f1ee.📒 Files selected for processing (1)
src/libs/libAudio2.cppIncluded review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
@Nmzik on GitHub · 2026-09-25 22:19 UTC · original
@EmK530 Thanks!