fix: PSP boot crash, audio stability, and streaming MP3 player#19
fix: PSP boot crash, audio stability, and streaming MP3 player#19AndrewAltimit merged 9 commits intomainfrom
Conversation
The default feature `kernel-mode` enabled `psp/kernel`, causing the rust-psp global allocator to use partition 1 (kernel memory) for all heap allocations. Since the EBOOT runs in user mode, the kernel partition is inaccessible — every allocation returned ILLEGAL_PARTITION, triggering an OOM panic on the first heap allocation (font atlas). Change default features to empty so the allocator uses partition 2 (user memory). Kernel features remain available via `--features kernel-mode` for real PSP hardware with CFW kernel access. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Gemini AI Code ReviewIssues (if any)(none) Previous Issues (for incremental reviews)(none) Suggestions (if any)
Notes
Generated by Gemini AI (gemini-3-flash-preview). Supplementary to human reviews. |
The codec NID scan + stub extraction was running every 2s for up to 60s (30 attempts), causing periodic stutter in games. Reduce to 3 attempts at 15s intervals (45s total) so only a few hiccups occur before the fallback to loading AV modules directly. Also clarify kernel-mode feature comments per review: kernel-exception is intentionally excluded from the kernel-mode bundle (broken on PSP-3000 + 6.20 PRO-C). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Gemini AI Incremental ReviewThis is an incremental review focusing on changes since the last review. Issues (if any)(none) Previous Issues (for incremental reviews)(none) Suggestions (if any)
Notes
Generated by Gemini AI (gemini-3-flash-preview). Supplementary to human reviews. |
…equency The EBOOT never loaded AVCODEC/MPEGBASE/MP3 modules, so the PRX overlay's codec NID scan always failed repeatedly (causing periodic stutter) before falling back to loading modules itself. Now the EBOOT calls sceUtilityLoadModule for all three AV modules during init, so the PRX finds them on its first scan attempt. Also reduce the PRX scan from 30 attempts x 2s to 3 attempts x 15s as a safety net for games that load codecs late. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Loading AvCodec/AvMpegBase/AvMp3 via sceUtilityLoadModule conflicts with the EBOOT's statically-linked sceMp3 imports -- both resolve to the same kernel codec but through different paths, causing sceMp3Decode to hang when the user plays audio. The PRX overlay handles its own module loading via its fallback path (load_av_modules after 3 scan attempts). With the reduced scan frequency (3x15s) the stutter is minimal. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Gemini AI Incremental ReviewThis is an incremental review focusing on changes since the last review. Issues (if any)(none) Previous Issues (for incremental reviews)
Suggestions (if any)
Notes
Generated by Gemini AI (gemini-3-flash-preview). Supplementary to human reviews. |
|
Note on the sceUtilityLoadModule add/revert (commits 5e90111 -> 9f566f3): We tried pre-loading However, on real hardware this caused a deadlock when the EBOOT's music player tried to play audio. The root cause: the EBOOT statically imports The PRX's own fallback mechanism ( Takeaway: Don't mix |
…n deadlock On single-core PSP with preemptive scheduling, the audio thread (priority 16/high) preempting the main thread (priority 32/low) while it holds the SpinMutex causes deadlock -- the audio thread spins forever waiting for a lock that the main thread can never release. Replace SharedAudioState/SpinMutex with individual AtomicBool/AtomicU32 fields for lock-free reads and writes with zero contention. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Gemini AI Incremental ReviewThis is an incremental review focusing on changes since the last review. Issues
Previous Issues
Suggestions
Notes
Generated by Gemini AI (gemini-3-flash-preview). Supplementary to human reviews. |
- Leak JoinHandles with core::mem::forget() to prevent sceKernelTerminateDeleteThread from killing worker threads on drop - Defer sceUtilityLoadModule (AvCodec/AvMpegBase/AvMp3) to first play to avoid ME EDRAM conflict with PRX overlay at boot time - Remove sceMp3InitResource probe from audio.rs (SDK now skips ID3v2) - Remove all file-based debug logging and atomic debug counters - Use sceKernelDelayThread directly for idle sleep (avoids TLS) - Switch psp dependency to local path for ID3v2 skip fix Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace sceMp3 with sceAudiocodec for EBOOT MP3 playback. The sceMp3 API is unstable on real PSP hardware (PSP-3000 + 6.20 PRO-C), crashing after ~2-3 song switches regardless of handle reuse strategy. New approach streams MP3 from file using a fixed 32KB read buffer with frame-by-frame sceAudiocodec decoding -- zero large heap allocations, matching the PRX plugin's proven pattern. Decoder EDRAM and audio channel are allocated once and reused across all songs. Also adds OASIS OS detection to the PRX plugin so it skips audio codec usage when the EBOOT is running (both share the ME coprocessor's EDRAM). Updates rust-psp dependency from fix/mp3-id3v2-skip branch to main (ID3v2 skip fix, reload APIs, and stability docs now merged upstream). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Audio player rewrite: sceMp3 -> sceAudiocodec + file streamingThe root cause of the 3rd-song crash was identified through extensive testing on real PSP-3000 hardware: sceMp3 API instability: The
PPSSPP does not reproduce any of these issues. Working solution: Replaced sceMp3 with
The sceMp3 findings and audiocodec recommendation have been documented upstream in rust-psp (AndrewAltimit/rust-psp#9, now merged to main). The Tested: 5+ consecutive song switches with no crashes, pause/resume works, volume control works. |
Gemini AI Incremental ReviewThis is an incremental review focusing on changes since the last review. Issues
Previous Issues
Suggestions
Notes
Generated by Gemini AI (gemini-3-flash-preview). Supplementary to human reviews. |
Automated fix by Claude in response to Gemini/Codex review. Iteration: 1/5 Co-Authored-By: AI Review Agent <noreply@anthropic.com>
Review Response Agent (Iteration 1)Status: Changes committed and pushed Commit: Fixed Issues
Ignored Issues
Deferred to Human
Notes
Automated summary of agent fixes. |
Gemini AI Incremental ReviewThis is an incremental review focusing on changes since the last review. Issues
Previous Issues
Suggestions
Notes
Generated by Gemini AI (gemini-3-flash-preview). Supplementary to human reviews. |
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Review Response Agent (Iteration 2)Status: No changes needed Fixed Issues
Ignored Issues
Deferred to Human
Notes
The agent reviewed feedback but determined no code changes were required. |
Gemini AI Incremental ReviewThis is an incremental review focusing on changes since the last review. Issues
Previous Issues
Suggestions
Notes
Generated by Gemini AI (gemini-3-flash-preview). Supplementary to human reviews. |
Review Response Agent (Iteration 3)Status: No changes needed Fixed Issues
Ignored Issues
Deferred to Human
Notes
The agent reviewed feedback but determined no code changes were required. |
Summary
Audio Architecture
The
sceMp3*high-level API is unstable on real PSP hardware (PSP-3000 + 6.20 PRO-C) -- crashes after ~2-3 song switches regardless of handle reuse strategy (drop+new, reload, reload_owned, timing delays). PPSSPP does not reproduce the issue.New approach: stream MP3 from file using a fixed 32KB read buffer with frame-by-frame
sceAudiocodecdecoding. Zero large heap allocations, matching the PRX plugin's proven pattern. TheAudiocodecDecoderEDRAM andAudioChannelare allocated once and reused indefinitely across songs.Changes
Boot fixes:
SceKernelPrimaryUserPartitioninstead of kernel partition for volatile memoryAudio player rewrite (
audio.rs):sceAudiocodecframe-by-frame decoder replacessceMp3streaming APIpsp::mp3::find_syncpsp::mp3::skip_id3v2PRX plugin:
Dependency:
pspcrate updated fromfix/mp3-id3v2-skipbranch tomainTest plan
Generated with Claude Code