Browse files

fixes embedded art not being read from FLAC files

  • Loading branch information...
1 parent acd7eba commit e369fc34f6e954e8e2d00226803c7c0f699ddc8d Jonathan Marshall committed Oct 13, 2012
Showing with 29 additions and 0 deletions.
  1. +28 −0 xbmc/music/tags/TagLoaderTagLib.cpp
  2. +1 −0 xbmc/music/tags/TagLoaderTagLib.h
View
28 xbmc/music/tags/TagLoaderTagLib.cpp
@@ -197,6 +197,10 @@ bool CTagLoaderTagLib::Load(const string& strFileName, CMusicInfoTag& tag, Embed
else if (xiph)
ParseXiphComment(xiph, art, tag);
+ // art for flac files is outside the tag
+ if (flacFile)
+ SetFlacArt(flacFile, art, tag);
+
// Add APE tags over the top of ID3 tags if we want to prioritize them
if (ape && g_advancedSettings.m_prioritiseAPEv2tags)
ParseAPETag(ape, art, tag);
@@ -520,6 +524,30 @@ bool CTagLoaderTagLib::ParseGenericTag(Tag *generic, EmbeddedArt *art, CMusicInf
return true;
}
+void CTagLoaderTagLib::SetFlacArt(FLAC::File *flacFile, EmbeddedArt *art, CMusicInfoTag &tag)
+{
+ FLAC::Picture *cover[2] = {};
+ List<FLAC::Picture *> pictures = flacFile->pictureList();
+ for (List<FLAC::Picture *>::ConstIterator i = pictures.begin(); i != pictures.end(); ++i)
+ {
+ FLAC::Picture *picture = *i;
+ if (picture->type() == FLAC::Picture::FrontCover)
+ cover[0] = picture;
+ else // anything else is taken as second priority
+ cover[1] = picture;
+ }
+ for (unsigned int i = 0; i < 2; i++)
+ {
+ if (cover[i])
+ {
+ tag.SetCoverArtInfo(cover[i]->data().size(), cover[i]->mimeType().to8Bit(true));
+ if (art)
+ art->set((const uint8_t*)cover[i]->data().data(), cover[i]->data().size(), cover[i]->mimeType().to8Bit(true));
+ return; // one is enough
+ }
+ }
+}
+
const vector<string> CTagLoaderTagLib::GetASFStringList(const List<ASF::Attribute>& list)
{
vector<string> values;
View
1 xbmc/music/tags/TagLoaderTagLib.h
@@ -68,4 +68,5 @@ class CTagLoaderTagLib
bool ParseXiphComment(TagLib::Ogg::XiphComment *id3v2, MUSIC_INFO::EmbeddedArt *art, MUSIC_INFO::CMusicInfoTag& tag);
bool ParseMP4Tag(TagLib::MP4::Tag *mp4, MUSIC_INFO::EmbeddedArt *art, MUSIC_INFO::CMusicInfoTag& tag);
bool ParseGenericTag(TagLib::Tag *generic, MUSIC_INFO::EmbeddedArt *art, MUSIC_INFO::CMusicInfoTag& tag);
+ void SetFlacArt(TagLib::FLAC::File *flacFile, MUSIC_INFO::EmbeddedArt *art, MUSIC_INFO::CMusicInfoTag &tag);
};

0 comments on commit e369fc3

Please sign in to comment.