fix: Mp3Decoder ID3v2 skip, reload APIs, and stability docs#9
Merged
AndrewAltimit merged 8 commits intomainfrom Feb 15, 2026
Merged
fix: Mp3Decoder ID3v2 skip, reload APIs, and stability docs#9AndrewAltimit merged 8 commits intomainfrom
AndrewAltimit merged 8 commits intomainfrom
Conversation
Set mp3_stream_start to after the ID3v2 tag header so the PSP's hardware MP3 decoder sees raw frames instead of tag metadata. Without this, sceMp3Init returns 0x807f00fd on files with ID3v2 tags. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The PSP crashes when sceMp3TermResource() + sceMp3InitResource() are called in sequence (e.g. stopping one song and starting another). release() frees the handle via sceMp3ReleaseMp3Handle but skips the global TermResource, keeping the MP3 subsystem alive for reuse. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
core::mem::forget(self) prevented TermResource but also leaked the Vec<u8> data/mp3_buf/pcm_buf — exhausting PSP RAM after a few songs. Use ManuallyDrop + drop_in_place to free the Vecs while still skipping the Drop impl (which calls sceMp3TermResource). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
new() calls sceMp3InitResource (first-time init). new_reuse() skips it (resource already initialized from prior session). This lets callers do init-once + release/reuse without stacking InitResource calls, which crashes on real PSP after ~2 calls. Also adds suppress_drop() for clean error-path cleanup without triggering the Drop impl's TermResource call. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The PSP's sceMp3 Release→Reserve cycle crashes on real hardware. reload() reuses the existing handle by resetting the play position and re-feeding new data, avoiding Release/Reserve/Term/Init entirely. Changes: - Strip ID3v2 tag before storing data (mp3_stream_start always 0) - Use large mp3_stream_end sentinel so handle works for any file size - Add reload() method: reset + replace data + re-feed - Remove release/new_reuse/suppress_drop (no longer needed) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
reload_owned() takes ownership of the Vec<u8> and drains the ID3v2 prefix in-place, avoiding a full copy of the MP3 data. Combined with reload(), this gives callers a choice between borrowing and owning. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The sceMp3* API is unstable for handle reuse on real PSP hardware (PSP-3000 + 6.20 PRO-C). All approaches (drop+new, reload, reload_owned) crash after ~2-3 songs. PPSSPP does not reproduce the issue. Document that sceAudiocodec (frame-by-frame) is the recommended API for MP3 playback with song switching, and cross-reference the mp3 module's find_sync/skip_id3v2 helpers from the audiocodec docs. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Gemini AI Code ReviewIssues (if any)
Previous Issues (for incremental reviews)(none) Suggestions (if any)
Notes
Generated by Gemini AI (gemini-3-flash-preview). Supplementary to human reviews. |
Extract feed_data into a free function (feed_data_raw) so initial data feeding can happen before the Mp3Decoder struct is constructed. On error, the Vec allocations (_data, mp3_buf, pcm_buf) now drop normally via Rust scoping instead of being leaked by core::mem::forget. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Owner
Author
Review Response Agent (Iteration 1)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. Previous Issues (for incremental reviews)
Issues (if any)
Suggestions (if any)
Notes
Generated by Gemini AI (gemini-3-flash-preview). Supplementary to human reviews. |
Owner
Author
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Mp3Decoder::new()andcreate()now strip ID3v2 tags before feeding data to the decoder, fixingsceMp3Initerror0x807f00fdon MP3 files with metadata tagsreload()andreload_owned()methods for swapping song data without releasing the decoder handle (avoids the Release->Reserve->Init cycle)release()method andnew_reuse()constructor for granular control over the sceMp3 resource lifecyclesceMp3*API is unstable for handle reuse on real PSP hardware (PSP-3000 + 6.20 PRO-C) -- crashes after ~2-3 songs regardless of approach. Recommendsaudiocodec::AudiocodecDecoderfor multi-song playback, with cross-references tomp3::find_syncandmp3::skip_id3v2helpersDetails
Tested extensively on real PSP-3000 hardware with 6.20 PRO-C CFW. The
sceMp3*high-level API works fine for single-song playback but is fundamentally unreliable when reusing handles across songs -- all of the following approaches crash after 2-3 songs:release()+new_reuse()(Release->Reserve, skip Term/Init)reload()/reload_owned()(ResetPlayPosition + re-feed, no Release at all)PPSSPP does not reproduce the issue. The working solution for multi-song playback is
sceAudiocodec(frame-by-frame decoding with a single EDRAM allocation), which is already wrapped bypsp::audiocodec::AudiocodecDecoder.Test plan
Mp3Decoder::new()plays MP3 files with ID3v2 tags (previously returned error0x807f00fd)Mp3Decoder::new()still plays MP3 files without ID3v2 tagsfind_sync()andskip_id3v2()are accessible as public utilitiesAudiocodecDecoderdocs reference the stability warningGenerated with Claude Code