Skip to content

Commit

Permalink
fixes embedded art not being read from FLAC files
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Marshall committed Oct 13, 2012
1 parent acd7eba commit e369fc3
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
28 changes: 28 additions & 0 deletions xbmc/music/tags/TagLoaderTagLib.cpp
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions xbmc/music/tags/TagLoaderTagLib.h
Expand Up @@ -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.