Skip to content

Commit edaf5ea

Browse files
PPN-SDDarthGandalf
authored andcommitted
Support both taglib-1 and taglib-2
Patch from clementine-player#7314 Fixes clementine-player#7313 Close clementine-player#7314
1 parent 604ef7d commit edaf5ea

File tree

3 files changed

+50
-0
lines changed

3 files changed

+50
-0
lines changed

ext/libclementine-tagreader/cloudstream.cpp

+24
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,11 @@ void CloudStream::Precache() {
9191
clear();
9292
}
9393

94+
#if (TAGLIB_MAJOR_VERSION == 2)
9495
TagLib::ByteVector CloudStream::readBlock(size_t length) {
96+
#else
97+
TagLib::ByteVector CloudStream::readBlock(ulong length) {
98+
#endif
9599
const uint start = cursor_;
96100
const uint end = qMin(cursor_ + length - 1, length_ - 1);
97101

@@ -144,11 +148,19 @@ void CloudStream::writeBlock(const TagLib::ByteVector&) {
144148
qLog(Debug) << Q_FUNC_INFO << "not implemented";
145149
}
146150

151+
#if (TAGLIB_MAJOR_VERSION == 2)
147152
void CloudStream::insert(const TagLib::ByteVector&, TagLib::offset_t, size_t) {
153+
#else
154+
void CloudStream::insert(const TagLib::ByteVector&, ulong, ulong) {
155+
#endif
148156
qLog(Debug) << Q_FUNC_INFO << "not implemented";
149157
}
150158

159+
#if (TAGLIB_MAJOR_VERSION == 2)
151160
void CloudStream::removeBlock(TagLib::offset_t, size_t) {
161+
#else
162+
void CloudStream::removeBlock(ulong, ulong) {
163+
#endif
152164
qLog(Debug) << Q_FUNC_INFO << "not implemented";
153165
}
154166

@@ -159,7 +171,11 @@ bool CloudStream::readOnly() const {
159171

160172
bool CloudStream::isOpen() const { return true; }
161173

174+
#if (TAGLIB_MAJOR_VERSION == 2)
162175
void CloudStream::seek(TagLib::offset_t offset, TagLib::IOStream::Position p) {
176+
#else
177+
void CloudStream::seek(long offset, TagLib::IOStream::Position p) {
178+
#endif
163179
switch (p) {
164180
case TagLib::IOStream::Beginning:
165181
cursor_ = offset;
@@ -178,11 +194,19 @@ void CloudStream::seek(TagLib::offset_t offset, TagLib::IOStream::Position p) {
178194

179195
void CloudStream::clear() { cursor_ = 0; }
180196

197+
#if (TAGLIB_MAJOR_VERSION == 2)
181198
TagLib::offset_t CloudStream::tell() const { return cursor_; }
182199

183200
TagLib::offset_t CloudStream::length() { return length_; }
184201

185202
void CloudStream::truncate(TagLib::offset_t) {
203+
#else
204+
long CloudStream::tell() const { return cursor_; }
205+
206+
long CloudStream::length() { return length_; }
207+
208+
void CloudStream::truncate(long) {
209+
#endif
186210
qLog(Debug) << Q_FUNC_INFO << "not implemented";
187211
}
188212

ext/libclementine-tagreader/cloudstream.h

+14
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ class CloudStream : public QObject, public TagLib::IOStream {
3535

3636
// Taglib::IOStream
3737
virtual TagLib::FileName name() const;
38+
#if (TAGLIB_MAJOR_VERSION == 2)
3839
virtual TagLib::ByteVector readBlock(size_t length);
3940
virtual void writeBlock(const TagLib::ByteVector&);
4041
virtual void insert(const TagLib::ByteVector&, TagLib::offset_t, size_t);
@@ -46,6 +47,19 @@ class CloudStream : public QObject, public TagLib::IOStream {
4647
virtual TagLib::offset_t tell() const;
4748
virtual TagLib::offset_t length();
4849
virtual void truncate(TagLib::offset_t);
50+
#else
51+
virtual TagLib::ByteVector readBlock(ulong length);
52+
virtual void writeBlock(const TagLib::ByteVector&);
53+
virtual void insert(const TagLib::ByteVector&, ulong, ulong);
54+
virtual void removeBlock(ulong, ulong);
55+
virtual bool readOnly() const;
56+
virtual bool isOpen() const;
57+
virtual void seek(long offset, TagLib::IOStream::Position p);
58+
virtual void clear();
59+
virtual long tell() const;
60+
virtual long length();
61+
virtual void truncate(long);
62+
#endif
4963

5064
google::sparsetable<char>::size_type cached_bytes() const {
5165
return cache_.num_nonempty();

ext/libclementine-tagreader/tagreader.cpp

+12
Original file line numberDiff line numberDiff line change
@@ -1376,9 +1376,15 @@ bool TagReader::ReadCloudFile(const QUrl& download_url, const QString& title,
13761376
std::unique_ptr<TagLib::File> tag;
13771377
if (mime_type == "audio/mpeg" &&
13781378
title.endsWith(".mp3", Qt::CaseInsensitive)) {
1379+
#if (TAGLIB_MAJOR_VERSION == 2)
13791380
tag.reset(new TagLib::MPEG::File(stream.get(), true,
13801381
TagLib::AudioProperties::Accurate,
13811382
TagLib::ID3v2::FrameFactory::instance()));
1383+
#else
1384+
tag.reset(new TagLib::MPEG::File(stream.get(),
1385+
TagLib::ID3v2::FrameFactory::instance(),
1386+
TagLib::AudioProperties::Accurate));
1387+
#endif
13821388
} else if (mime_type == "audio/mp4" ||
13831389
(mime_type == "audio/mpeg" &&
13841390
title.endsWith(".m4a", Qt::CaseInsensitive))) {
@@ -1398,9 +1404,15 @@ bool TagReader::ReadCloudFile(const QUrl& download_url, const QString& title,
13981404
TagLib::AudioProperties::Accurate));
13991405
} else if (mime_type == "application/x-flac" || mime_type == "audio/flac" ||
14001406
mime_type == "audio/x-flac") {
1407+
#if (TAGLIB_MAJOR_VERSION == 2)
14011408
tag.reset(new TagLib::FLAC::File(stream.get(), true,
14021409
TagLib::AudioProperties::Accurate,
14031410
TagLib::ID3v2::FrameFactory::instance()));
1411+
#else
1412+
tag.reset(new TagLib::FLAC::File(stream.get(),
1413+
TagLib::ID3v2::FrameFactory::instance(),
1414+
true, TagLib::AudioProperties::Accurate));
1415+
#endif
14041416
} else if (mime_type == "audio/x-ms-wma") {
14051417
tag.reset(new TagLib::ASF::File(stream.get(), true,
14061418
TagLib::AudioProperties::Accurate));

0 commit comments

Comments
 (0)