mirror of
https://github.com/zarzet/SpotiFLAC-Mobile.git
synced 2026-07-26 05:51:18 +02:00
fix(metadata): shift stco/co64 chunk offsets when the ilst resizes
writeM4AFreeformTags changed the ilst size without updating chunk offsets, which broke playback for faststart files (moov before mdat) after any ISRC/label/ReplayGain write. Reuses the AC-4 path's shiftChunkOffsets.
This commit is contained in:
@@ -1676,6 +1676,14 @@ func writeM4AFreeformTags(filePath string, remove map[string]struct{}, tags []m4
|
||||
if err := writeAtomSize(updated, path.moov, path.moov.size+delta); err != nil {
|
||||
return err
|
||||
}
|
||||
// Keep sample pointers valid when moov precedes mdat: every stco/co64
|
||||
// entry at or beyond the resized ilst must shift with it.
|
||||
if delta != 0 {
|
||||
if moov, ok := findChildMP4(updated, 0, int64(len(updated)), "moov"); ok {
|
||||
shiftChunkOffsets(updated, moov, path.ilst.offset, delta)
|
||||
}
|
||||
}
|
||||
|
||||
// Release the read handle before replacing the file (required on Windows).
|
||||
f.Close()
|
||||
return writeFileAtomic(filePath, updated, 0o644)
|
||||
|
||||
Reference in New Issue
Block a user