Fix flac coverart may not be displayed #539
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
moode/www/inc/Zend/Media/Flac.php
Lines 171 to 175 in 0fbbe1e
but sometimes flac has multiple APPLICATION metadata block like this
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.