diff options
author | Urs Fleisch <ufleisch@users.sourceforge.net> | 2020-12-12 10:47:57 +0100 |
---|---|---|
committer | Urs Fleisch <ufleisch@users.sourceforge.net> | 2020-12-21 11:09:15 +0100 |
commit | 7ec1127f3e6727eeb631d9480bc4e2fd927f9ee7 (patch) | |
tree | 0229ec80367bd997c009c6e87e6f8b55a9b3aaf8 /taglib/flac | |
parent | 30d839538d4330f63e9e21e26bcdfb331b802740 (diff) |
FLAC: Store comment block before picture block (#954)
When the picture block is large and comes before the comment block,
Windows will no longer display the tags. This can be fixed by
storing the comment block before the picture block instead of
appending it at the end.
Diffstat (limited to 'taglib/flac')
-rw-r--r-- | taglib/flac/flacfile.cpp | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/taglib/flac/flacfile.cpp b/taglib/flac/flacfile.cpp index 7f437194..ada215db 100644 --- a/taglib/flac/flacfile.cpp +++ b/taglib/flac/flacfile.cpp @@ -187,16 +187,24 @@ bool FLAC::File::save() // Replace metadata blocks - for(BlockIterator it = d->blocks.begin(); it != d->blocks.end(); ++it) { + MetadataBlock *commentBlock = + new UnknownMetadataBlock(MetadataBlock::VorbisComment, d->xiphCommentData); + for(BlockIterator it = d->blocks.begin(); it != d->blocks.end();) { if((*it)->code() == MetadataBlock::VorbisComment) { - // Set the new Vorbis Comment block + // Remove the old Vorbis Comment block delete *it; - d->blocks.erase(it); - break; + it = d->blocks.erase(it); + continue; } + if(commentBlock && (*it)->code() == MetadataBlock::Picture) { + // Set the new Vorbis Comment block before the first picture block + d->blocks.insert(it, commentBlock); + commentBlock = 0; + } + ++it; } - - d->blocks.append(new UnknownMetadataBlock(MetadataBlock::VorbisComment, d->xiphCommentData)); + if(commentBlock) + d->blocks.append(commentBlock); // Render data for the metadata blocks |