music: fix largesize MP4 box content offset in EmbeddedLyrics
- Commit
5c9242d5ec4517f1c039a2e7ec0ee8880e3ed95b- Author
- Vayun Mathur <[email protected]>
- When
- 2026-11-07 10:34 UTC (29 days ago)
- Parents
4d88895
boxEnd honoured the 64-bit largesize form (declared size 1) when computing a box's end, but readBoxRange always reported the content as starting after the plain 8-byte header. A largesize moov was therefore scanned eight bytes early and its ilst was never found, so lyrics in such files silently read as absent. Content now starts after the 16-byte largesize header. Found by a new synthetic-file test in EmbeddedLyricsTest (kept with the coverage work); verified by that test passing. (cherry picked from commit 2920d323e52ae06a23bbf8be637e412f0c98a3f8)
Diff
music/src/main/java/com/vayunmathur/music/platform/EmbeddedLyrics.kt
diff --git a/music/src/main/java/com/vayunmathur/music/platform/EmbeddedLyrics.kt b/music/src/main/java/com/vayunmathur/music/platform/EmbeddedLyrics.ktindex b519264a2c..74b2d34986 100644--- a/music/src/main/java/com/vayunmathur/music/platform/EmbeddedLyrics.kt+++ b/music/src/main/java/com/vayunmathur/music/platform/EmbeddedLyrics.kt@@ -261,7 +261,10 @@ object EmbeddedLyrics { head.flip() val declared = head.int.toLong() and 0xffffffffL val type = String(ByteArray(MAGIC_TEXT_LENGTH) { head.get() }, Charsets.ISO_8859_1)- val contentStart = position + MP4_BOX_HEADER+ // A largesize box (declared == 1) carries an extra 8-byte size field,+ // so its content starts after the 16-byte header, not the usual 8.+ val contentStart = position ++ if (declared == MP4_LARGE_MARKER) MP4_LARGE_HEADER else MP4_BOX_HEADER.toLong() val end = boxEnd(channel, position, size, declared) ?: return null if (end <= position || end > size) return null return BoxRange(type == "moov", contentStart, end)