Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix flac coverart may not be displayed #539

Merged
merged 1 commit into from
Aug 28, 2022

Conversation

yn386
Copy link
Contributor

@yn386 yn386 commented Aug 27, 2022

This PR fixes following problem.

Problem:

Flac coverart may not be displayed.

moOde Version

Release 8.1.2

Environment

Raspi: Pi-3B 1.2 1GB
Audio: Pi HDMI 1

How to reproduce:

Play flac file that have 7 or more metadata block before PICTURE metablock.

Detail of changes:

To prevent corrupt header from causing endless loop, only first 7 metadata blocks are processed and others are ignored here:

// r44d exit loop if > 7 iterations
$count++;
if ($count > 7) {
break;
}

but sometimes flac has multiple APPLICATION metadata block like this

[STREAMINFO]
[VORBIS_COMMENT]
[SEEKTABLE]
[APPLICATION]
[APPLICATION]
[APPLICATION]
[APPLICATION]
[APPLICATION]
[PICTURE]
[PADDING]

This is not corrupted flac and compatible with flac specification.

So I made changes instead of counting metadata block to prevent endless loop with coruupted files.

  • Check whether metadata indicates 'invalid'.
    According to the flac specification, BLOCK_TYPE 127 indicates 'invalid' to avoid confution with a frame sync code.
    So if metadata block type was 127, the flac is able to be regarded as corrupted file.

  • Check whether current file offset is in the file.
    If Last-metadata-block flag is still 0 until the end of file, the flac is able to be regarded as corrupted file.

Effect:

Coverart is displayed when playing flac file that have 7 or more metadata block before PICTURE metablock.

@moodeaudio
Copy link
Contributor

Looks like a nice fix :-)

I'll merge and test this weekend.

@moodeaudio moodeaudio merged commit 9fc8a19 into moode-player:develop Aug 28, 2022
@yn386 yn386 deleted the fix-flac-coverart-2 branch August 30, 2022 12:36
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.

None yet

2 participants