Skip to content

fix(flac): write a valid last metadata block header - #113

Open
mathiiiiiis wants to merge 1 commit into
ClementBeal:mainfrom
mathiiiiiis:fix/flac-block-header
Open

fix(flac): write a valid last metadata block header#113
mathiiiiiis wants to merge 1 commit into
ClementBeal:mainfrom
mathiiiiiis:fix/flac-block-header

Conversation

@mathiiiiiis

Copy link
Copy Markdown

Problem

FLAC files edited with updateMetadata are rejected with "invalid block type 127"

Cause

_writeBlock uses 255 | blockId, which is 0xFF for any blockId and sets all seven type bits alongside the flag

_parseMetadataBlock also drops types 4 and 6, and regenerated blocks pass isLastBlock: false, so files ending on a comment or picture carried no flag at all

Fix

write() emits headers after collecting all blocks, so the flag lands on the last one. Also keeps seek tables and writes ISO 8601 dates*

Tests

New test/writers/flac_writer_test.dart, run against no_picture.flac and a new picture_last.flac fixture. The first two failed on main before

Verified on Android with flac -t


* I will split the date change into a separate commit from the block header fix if you'd prefer that (lib/src/writers/flac_writer.dart, 137)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant