contrib/kodi/taglib.patch

338 lines
15 KiB
Diff

diff --git a/xbmc/music/tags/TagLibVFSStream.cpp b/xbmc/music/tags/TagLibVFSStream.cpp
index 1d2b454abbfe3..2008aba187e73 100644
--- a/xbmc/music/tags/TagLibVFSStream.cpp
+++ b/xbmc/music/tags/TagLibVFSStream.cpp
@@ -11,6 +11,7 @@
#include <limits.h>
+#include <taglib/taglib.h>
#include <taglib/tiostream.h>
using namespace XFILE;
@@ -90,7 +91,11 @@ void TagLibVFSStream::writeBlock(const ByteVector &data)
* \note This method is slow since it requires rewriting all of the file
* after the insertion point.
*/
+#if (TAGLIB_MAJOR_VERSION >= 2)
+void TagLibVFSStream::insert(const ByteVector& data, TagLib::offset_t start, size_t replace)
+#else
void TagLibVFSStream::insert(const ByteVector &data, TagLib::ulong start, TagLib::ulong replace)
+#endif
{
if (data.size() == replace)
{
@@ -180,7 +185,11 @@ void TagLibVFSStream::insert(const ByteVector &data, TagLib::ulong start, TagLib
* \note This method is slow since it involves rewriting all of the file
* after the removed portion.
*/
+#if (TAGLIB_MAJOR_VERSION >= 2)
+void TagLibVFSStream::removeBlock(TagLib::offset_t start, size_t length)
+#else
void TagLibVFSStream::removeBlock(TagLib::ulong start, TagLib::ulong length)
+#endif
{
TagLib::ulong bufferLength = bufferSize();
diff --git a/xbmc/music/tags/TagLibVFSStream.h b/xbmc/music/tags/TagLibVFSStream.h
index d56705535353c..e0030103a5767 100644
--- a/xbmc/music/tags/TagLibVFSStream.h
+++ b/xbmc/music/tags/TagLibVFSStream.h
@@ -10,6 +10,7 @@
#include "filesystem/File.h"
+#include <taglib/taglib.h>
#include <taglib/tiostream.h>
namespace MUSIC_INFO
@@ -56,7 +57,13 @@ namespace MUSIC_INFO
* \note This method is slow since it requires rewriting all of the file
* after the insertion point.
*/
+#if (TAGLIB_MAJOR_VERSION >= 2)
+ void insert(const TagLib::ByteVector& data,
+ TagLib::offset_t start = 0,
+ size_t replace = 0) override;
+#else
void insert(const TagLib::ByteVector &data, TagLib::ulong start = 0, TagLib::ulong replace = 0) override;
+#endif
/*!
* Removes a block of the file starting a \a start and continuing for
@@ -65,7 +72,11 @@ namespace MUSIC_INFO
* \note This method is slow since it involves rewriting all of the file
* after the removed portion.
*/
+#if (TAGLIB_MAJOR_VERSION >= 2)
+ void removeBlock(TagLib::offset_t start = 0, size_t length = 0) override;
+#else
void removeBlock(TagLib::ulong start = 0, TagLib::ulong length = 0) override;
+#endif
/*!
* Returns true if the file is read only (or if the file can not be opened).
diff --git a/xbmc/music/tags/TagLoaderTagLib.cpp b/xbmc/music/tags/TagLoaderTagLib.cpp
index 6eb591a0c4b4f..c1b36318b2e0d 100644
--- a/xbmc/music/tags/TagLoaderTagLib.cpp
+++ b/xbmc/music/tags/TagLoaderTagLib.cpp
@@ -500,19 +500,19 @@ bool CTagLoaderTagLib::ParseTag(APE::Tag *ape, EmbeddedArt *art, CMusicInfoTag&
for (APE::ItemListMap::ConstIterator it = itemListMap.begin(); it != itemListMap.end(); ++it)
{
if (it->first == "ARTIST")
- SetArtist(tag, StringListToVectorString(it->second.toStringList()));
+ SetArtist(tag, StringListToVectorString(it->second.values()));
else if (it->first == "ARTISTSORT")
- SetArtistSort(tag, StringListToVectorString(it->second.toStringList()));
+ SetArtistSort(tag, StringListToVectorString(it->second.values()));
else if (it->first == "ARTISTS")
- SetArtistHints(tag, StringListToVectorString(it->second.toStringList()));
+ SetArtistHints(tag, StringListToVectorString(it->second.values()));
else if (it->first == "ALBUMARTIST" || it->first == "ALBUM ARTIST")
- SetAlbumArtist(tag, StringListToVectorString(it->second.toStringList()));
+ SetAlbumArtist(tag, StringListToVectorString(it->second.values()));
else if (it->first == "ALBUMARTISTSORT")
- SetAlbumArtistSort(tag, StringListToVectorString(it->second.toStringList()));
+ SetAlbumArtistSort(tag, StringListToVectorString(it->second.values()));
else if (it->first == "ALBUMARTISTS" || it->first == "ALBUM ARTISTS")
- SetAlbumArtistHints(tag, StringListToVectorString(it->second.toStringList()));
+ SetAlbumArtistHints(tag, StringListToVectorString(it->second.values()));
else if (it->first == "COMPOSERSORT")
- SetComposerSort(tag, StringListToVectorString(it->second.toStringList()));
+ SetComposerSort(tag, StringListToVectorString(it->second.values()));
else if (it->first == "ALBUM")
tag.SetAlbum(it->second.toString().to8Bit(true));
else if (it->first == "TITLE")
@@ -528,7 +528,7 @@ bool CTagLoaderTagLib::ParseTag(APE::Tag *ape, EmbeddedArt *art, CMusicInfoTag&
else if (it->first == "ORIGINALYEAR")
tag.SetOriginalDate(it->second.toString().to8Bit(true));
else if (it->first == "GENRE")
- SetGenre(tag, StringListToVectorString(it->second.toStringList()));
+ SetGenre(tag, StringListToVectorString(it->second.values()));
else if (it->first == "MOOD")
tag.SetMood(it->second.toString().to8Bit(true));
else if (it->first == "COMMENT")
@@ -538,32 +538,32 @@ bool CTagLoaderTagLib::ParseTag(APE::Tag *ape, EmbeddedArt *art, CMusicInfoTag&
else if (it->first == "ENCODEDBY")
{}
else if (it->first == "COMPOSER")
- AddArtistRole(tag, "Composer", StringListToVectorString(it->second.toStringList()));
+ AddArtistRole(tag, "Composer", StringListToVectorString(it->second.values()));
else if (it->first == "CONDUCTOR")
- AddArtistRole(tag, "Conductor", StringListToVectorString(it->second.toStringList()));
+ AddArtistRole(tag, "Conductor", StringListToVectorString(it->second.values()));
else if (it->first == "BAND")
- AddArtistRole(tag, "Band", StringListToVectorString(it->second.toStringList()));
+ AddArtistRole(tag, "Band", StringListToVectorString(it->second.values()));
else if (it->first == "ENSEMBLE")
- AddArtistRole(tag, "Ensemble", StringListToVectorString(it->second.toStringList()));
+ AddArtistRole(tag, "Ensemble", StringListToVectorString(it->second.values()));
else if (it->first == "LYRICIST")
- AddArtistRole(tag, "Lyricist", StringListToVectorString(it->second.toStringList()));
+ AddArtistRole(tag, "Lyricist", StringListToVectorString(it->second.values()));
else if (it->first == "WRITER")
- AddArtistRole(tag, "Writer", StringListToVectorString(it->second.toStringList()));
+ AddArtistRole(tag, "Writer", StringListToVectorString(it->second.values()));
else if ((it->first == "MIXARTIST") || (it->first == "REMIXER"))
- AddArtistRole(tag, "Remixer", StringListToVectorString(it->second.toStringList()));
+ AddArtistRole(tag, "Remixer", StringListToVectorString(it->second.values()));
else if (it->first == "ARRANGER")
- AddArtistRole(tag, "Arranger", StringListToVectorString(it->second.toStringList()));
+ AddArtistRole(tag, "Arranger", StringListToVectorString(it->second.values()));
else if (it->first == "ENGINEER")
- AddArtistRole(tag, "Engineer", StringListToVectorString(it->second.toStringList()));
+ AddArtistRole(tag, "Engineer", StringListToVectorString(it->second.values()));
else if (it->first == "PRODUCER")
- AddArtistRole(tag, "Producer", StringListToVectorString(it->second.toStringList()));
+ AddArtistRole(tag, "Producer", StringListToVectorString(it->second.values()));
else if (it->first == "DJMIXER")
- AddArtistRole(tag, "DJMixer", StringListToVectorString(it->second.toStringList()));
+ AddArtistRole(tag, "DJMixer", StringListToVectorString(it->second.values()));
else if (it->first == "MIXER")
- AddArtistRole(tag, "Mixer", StringListToVectorString(it->second.toStringList()));
+ AddArtistRole(tag, "Mixer", StringListToVectorString(it->second.values()));
else if (it->first == "PERFORMER")
// Picard uses PERFORMER tag as musician credits list formatted "name (instrument)"
- AddArtistInstrument(tag, StringListToVectorString(it->second.toStringList()));
+ AddArtistInstrument(tag, StringListToVectorString(it->second.values()));
else if (it->first == "LABEL")
tag.SetRecordLabel(it->second.toString().to8Bit(true));
else if (it->first == "COMPILATION")
@@ -579,11 +579,11 @@ bool CTagLoaderTagLib::ParseTag(APE::Tag *ape, EmbeddedArt *art, CMusicInfoTag&
else if (it->first == "REPLAYGAIN_ALBUM_PEAK")
replayGainInfo.ParsePeak(ReplayGain::ALBUM, it->second.toString().toCString(true));
else if (it->first == "MUSICBRAINZ_ARTISTID")
- tag.SetMusicBrainzArtistID(SplitMBID(StringListToVectorString(it->second.toStringList())));
+ tag.SetMusicBrainzArtistID(SplitMBID(StringListToVectorString(it->second.values())));
else if (it->first == "MUSICBRAINZ_ALBUMARTISTID")
- tag.SetMusicBrainzAlbumArtistID(SplitMBID(StringListToVectorString(it->second.toStringList())));
+ tag.SetMusicBrainzAlbumArtistID(SplitMBID(StringListToVectorString(it->second.values())));
else if (it->first == "MUSICBRAINZ_ALBUMARTIST")
- SetAlbumArtist(tag, StringListToVectorString(it->second.toStringList()));
+ SetAlbumArtist(tag, StringListToVectorString(it->second.values()));
else if (it->first == "MUSICBRAINZ_ALBUMID")
tag.SetMusicBrainzAlbumID(it->second.toString().to8Bit(true));
else if (it->first == "MUSICBRAINZ_RELEASEGROUPID")
@@ -591,7 +591,7 @@ bool CTagLoaderTagLib::ParseTag(APE::Tag *ape, EmbeddedArt *art, CMusicInfoTag&
else if (it->first == "MUSICBRAINZ_TRACKID")
tag.SetMusicBrainzTrackID(it->second.toString().to8Bit(true));
else if (it->first == "MUSICBRAINZ_ALBUMTYPE")
- SetReleaseType(tag, StringListToVectorString(it->second.toStringList()));
+ SetReleaseType(tag, StringListToVectorString(it->second.values()));
else if (it->first == "BPM")
tag.SetBPM(it->second.toString().toInt());
else if (it->first == "MUSICBRAINZ_ALBUMSTATUS")
diff --git a/xbmc/music/tags/TagLibVFSStream.cpp b/xbmc/music/tags/TagLibVFSStream.cpp
index 2008aba187e73..c5f9c2473fe13 100644
--- a/xbmc/music/tags/TagLibVFSStream.cpp
+++ b/xbmc/music/tags/TagLibVFSStream.cpp
@@ -58,9 +58,17 @@ FileName TagLibVFSStream::name() const
/*!
* Reads a block of size \a length at the current get pointer.
*/
+#if (TAGLIB_MAJOR_VERSION >= 2)
+ByteVector TagLibVFSStream::readBlock(unsigned long length)
+#else
ByteVector TagLibVFSStream::readBlock(TagLib::ulong length)
+#endif
{
+#if (TAGLIB_MAJOR_VERSION >= 2)
+ ByteVector byteVector(static_cast<unsigned int>(length));
+#else
ByteVector byteVector(static_cast<TagLib::uint>(length));
+#endif
ssize_t read = m_file.Read(byteVector.data(), length);
if (read > 0)
byteVector.resize(read);
@@ -119,7 +127,11 @@ void TagLibVFSStream::insert(const ByteVector &data, TagLib::ulong start, TagLib
// First, make sure that we're working with a buffer that is longer than
// the *difference* in the tag sizes. We want to avoid overwriting parts
// that aren't yet in memory, so this is necessary.
+#if (TAGLIB_MAJOR_VERSION >= 2)
+ unsigned long bufferLength = bufferSize();
+#else
TagLib::ulong bufferLength = bufferSize();
+#endif
while (data.size() - replace > bufferLength)
bufferLength += bufferSize();
@@ -128,7 +140,11 @@ void TagLibVFSStream::insert(const ByteVector &data, TagLib::ulong start, TagLib
long readPosition = start + replace;
long writePosition = start;
ByteVector buffer;
+#if (TAGLIB_MAJOR_VERSION >= 2)
+ ByteVector aboutToOverwrite(static_cast<unsigned int>(bufferLength));
+#else
ByteVector aboutToOverwrite(static_cast<TagLib::uint>(bufferLength));
+#endif
// This is basically a special case of the loop below. Here we're just
// doing the same steps as below, but since we aren't using the same buffer
@@ -163,7 +179,11 @@ void TagLibVFSStream::insert(const ByteVector &data, TagLib::ulong start, TagLib
// Check to see if we just read the last block. We need to call clear()
// if we did so that the last write succeeds.
+#if (TAGLIB_MAJOR_VERSION >= 2)
+ if (static_cast<unsigned long>(bytesRead) < bufferLength)
+#else
if (TagLib::ulong(bytesRead) < bufferLength)
+#endif
clear();
// Seek to the write position and write our buffer. Increment the
@@ -191,14 +211,26 @@ void TagLibVFSStream::removeBlock(TagLib::offset_t start, size_t length)
void TagLibVFSStream::removeBlock(TagLib::ulong start, TagLib::ulong length)
#endif
{
+#if (TAGLIB_MAJOR_VERSION >= 2)
+ unsigned long bufferLength = bufferSize();
+#else
TagLib::ulong bufferLength = bufferSize();
+#endif
long readPosition = start + length;
long writePosition = start;
+#if (TAGLIB_MAJOR_VERSION >= 2)
+ ByteVector buffer(static_cast<unsigned int>(bufferLength));
+#else
ByteVector buffer(static_cast<TagLib::uint>(bufferLength));
+#endif
+#if (TAGLIB_MAJOR_VERSION >= 2)
+ unsigned long bytesRead = 1;
+#else
TagLib::ulong bytesRead = 1;
+#endif
while(bytesRead != 0)
{
@@ -207,7 +239,11 @@ void TagLibVFSStream::removeBlock(TagLib::ulong start, TagLib::ulong length)
if (read < 0)
return;// explicit error
+#if (TAGLIB_MAJOR_VERSION >= 2)
+ bytesRead = static_cast<unsigned long>(read);
+#else
bytesRead = static_cast<TagLib::ulong>(read);
+#endif
readPosition += bytesRead;
// Check to see if we just read the last block. We need to call clear()
diff --git a/xbmc/music/tags/TagLibVFSStream.h b/xbmc/music/tags/TagLibVFSStream.h
index e0030103a5767..2302c04dd92bd 100644
--- a/xbmc/music/tags/TagLibVFSStream.h
+++ b/xbmc/music/tags/TagLibVFSStream.h
@@ -37,7 +37,11 @@ namespace MUSIC_INFO
/*!
* Reads a block of size \a length at the current get pointer.
*/
+#if (TAGLIB_MAJOR_VERSION >= 2)
+ TagLib::ByteVector readBlock(unsigned long length) override;
+#else
TagLib::ByteVector readBlock(TagLib::ulong length) override;
+#endif
/*!
* Attempts to write the block \a data at the current get pointer. If the
@@ -121,7 +125,11 @@ namespace MUSIC_INFO
/*!
* Returns the buffer size that is used for internal buffering.
*/
+#if (TAGLIB_MAJOR_VERSION >= 2)
+ static unsigned int bufferSize() { return 1024; }
+#else
static TagLib::uint bufferSize() { return 1024; }
+#endif
private:
std::string m_strFileName;
diff --git a/xbmc/music/tags/TagLoaderTagLib.cpp b/xbmc/music/tags/TagLoaderTagLib.cpp
index c1b36318b2e0d..f4f676067a24c 100644
--- a/xbmc/music/tags/TagLoaderTagLib.cpp
+++ b/xbmc/music/tags/TagLoaderTagLib.cpp
@@ -472,7 +472,11 @@ bool CTagLoaderTagLib::ParseTag(ID3v2::Tag *id3v2, EmbeddedArt *art, MUSIC_INFO:
if (picture)
{
std::string mime = picture->mimeType().to8Bit(true);
+#if (TAGLIB_MAJOR_VERSION >= 2)
+ unsigned int size = picture->picture().size();
+#else
TagLib::uint size = picture->picture().size();
+#endif
tag.SetCoverArtInfo(size, mime);
if (art)
art->Set(reinterpret_cast<const uint8_t*>(picture->picture().data()), size, mime);
@@ -789,7 +793,11 @@ bool CTagLoaderTagLib::ParseTag(Ogg::XiphComment *xiph, EmbeddedArt *art, CMusic
std::string mime = pictures[i].mimeType().toCString();
if (mime.compare(0, 6, "image/") != 0)
continue;
+#if (TAGLIB_MAJOR_VERSION >= 2)
+ unsigned int size = pictures[i].data().size();
+#else
TagLib::uint size = pictures[i].data().size();
+#endif
tag.SetCoverArtInfo(size, mime);
if (art)
art->Set(reinterpret_cast<const uint8_t*>(pictures[i].data().data()), size, mime);