Skip to content

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

Merged
ClementBeal merged 1 commit into
ClementBeal:mainfrom
mathiiiiiis:fix/flac-block-header
Aug 7, 2026
Merged

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

Conversation

@mathiiiiiis

Copy link
Copy Markdown
Contributor

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)

@ClementBeal ClementBeal left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your PR!

Just a small review about a date format and we good to merge :)

Comment thread lib/src/writers/flac_writer.dart
@ClementBeal
ClementBeal merged commit 3d46d68 into ClementBeal:main Aug 7, 2026
3 checks passed
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.

2 participants