Skip to content

Commit 604ef7d

Browse files
bilde2910DarthGandalf
authored andcommitted
Fix usage of deprecated TagLib functions
1 parent c3daf0a commit 604ef7d

File tree

3 files changed

+28
-28
lines changed

3 files changed

+28
-28
lines changed

ext/libclementine-tagreader/cloudstream.cpp

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

94-
TagLib::ByteVector CloudStream::readBlock(ulong length) {
94+
TagLib::ByteVector CloudStream::readBlock(size_t length) {
9595
const uint start = cursor_;
9696
const uint end = qMin(cursor_ + length - 1, length_ - 1);
9797

@@ -144,11 +144,11 @@ void CloudStream::writeBlock(const TagLib::ByteVector&) {
144144
qLog(Debug) << Q_FUNC_INFO << "not implemented";
145145
}
146146

147-
void CloudStream::insert(const TagLib::ByteVector&, ulong, ulong) {
147+
void CloudStream::insert(const TagLib::ByteVector&, TagLib::offset_t, size_t) {
148148
qLog(Debug) << Q_FUNC_INFO << "not implemented";
149149
}
150150

151-
void CloudStream::removeBlock(ulong, ulong) {
151+
void CloudStream::removeBlock(TagLib::offset_t, size_t) {
152152
qLog(Debug) << Q_FUNC_INFO << "not implemented";
153153
}
154154

@@ -159,7 +159,7 @@ bool CloudStream::readOnly() const {
159159

160160
bool CloudStream::isOpen() const { return true; }
161161

162-
void CloudStream::seek(long offset, TagLib::IOStream::Position p) {
162+
void CloudStream::seek(TagLib::offset_t offset, TagLib::IOStream::Position p) {
163163
switch (p) {
164164
case TagLib::IOStream::Beginning:
165165
cursor_ = offset;
@@ -178,11 +178,11 @@ void CloudStream::seek(long offset, TagLib::IOStream::Position p) {
178178

179179
void CloudStream::clear() { cursor_ = 0; }
180180

181-
long CloudStream::tell() const { return cursor_; }
181+
TagLib::offset_t CloudStream::tell() const { return cursor_; }
182182

183-
long CloudStream::length() { return length_; }
183+
TagLib::offset_t CloudStream::length() { return length_; }
184184

185-
void CloudStream::truncate(long) {
185+
void CloudStream::truncate(TagLib::offset_t) {
186186
qLog(Debug) << Q_FUNC_INFO << "not implemented";
187187
}
188188

ext/libclementine-tagreader/cloudstream.h

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

3636
// Taglib::IOStream
3737
virtual TagLib::FileName name() const;
38-
virtual TagLib::ByteVector readBlock(ulong length);
38+
virtual TagLib::ByteVector readBlock(size_t length);
3939
virtual void writeBlock(const TagLib::ByteVector&);
40-
virtual void insert(const TagLib::ByteVector&, ulong, ulong);
41-
virtual void removeBlock(ulong, ulong);
40+
virtual void insert(const TagLib::ByteVector&, TagLib::offset_t, size_t);
41+
virtual void removeBlock(TagLib::offset_t, size_t);
4242
virtual bool readOnly() const;
4343
virtual bool isOpen() const;
44-
virtual void seek(long offset, TagLib::IOStream::Position p);
44+
virtual void seek(TagLib::offset_t offset, TagLib::IOStream::Position p);
4545
virtual void clear();
46-
virtual long tell() const;
47-
virtual long length();
48-
virtual void truncate(long);
46+
virtual TagLib::offset_t tell() const;
47+
virtual TagLib::offset_t length();
48+
virtual void truncate(TagLib::offset_t);
4949

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

ext/libclementine-tagreader/tagreader.cpp

+14-14
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ void TagReader::ReadFile(const QString& filename,
198198
// Find album artists
199199
TagLib::APE::ItemListMap::ConstIterator it = items.find("ALBUM ARTIST");
200200
if (it != items.end()) {
201-
TagLib::StringList album_artists = it->second.toStringList();
201+
TagLib::StringList album_artists = it->second.values();
202202
if (!album_artists.isEmpty()) {
203203
Decode(album_artists.front(), nullptr, song->mutable_albumartist());
204204
}
@@ -243,22 +243,22 @@ void TagReader::ReadFile(const QString& filename,
243243
}
244244

245245
if (items.contains("BPM")) {
246-
Decode(items["BPM"].toStringList().toString(", "), nullptr,
246+
Decode(items["BPM"].values().toString(", "), nullptr,
247247
song->mutable_performer());
248248
}
249249

250250
if (items.contains("PERFORMER")) {
251-
Decode(items["PERFORMER"].toStringList().toString(", "), nullptr,
251+
Decode(items["PERFORMER"].values().toString(", "), nullptr,
252252
song->mutable_performer());
253253
}
254254

255255
if (items.contains("COMPOSER")) {
256-
Decode(items["COMPOSER"].toStringList().toString(", "), nullptr,
256+
Decode(items["COMPOSER"].values().toString(", "), nullptr,
257257
song->mutable_composer());
258258
}
259259

260260
if (items.contains("GROUPING")) {
261-
Decode(items["GROUPING"].toStringList().toString(" "), nullptr,
261+
Decode(items["GROUPING"].values().toString(" "), nullptr,
262262
song->mutable_grouping());
263263
}
264264

@@ -565,8 +565,8 @@ void TagReader::ReadFile(const QString& filename,
565565
if (fileref->audioProperties()) {
566566
song->set_bitrate(fileref->audioProperties()->bitrate());
567567
song->set_samplerate(fileref->audioProperties()->sampleRate());
568-
song->set_length_nanosec(fileref->audioProperties()->length() *
569-
kNsecPerSec);
568+
song->set_length_nanosec(fileref->audioProperties()->lengthInMilliseconds() *
569+
kNsecPerMsec);
570570
}
571571

572572
// Get the filetype if we can
@@ -1376,9 +1376,9 @@ 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-
tag.reset(new TagLib::MPEG::File(stream.get(),
1380-
TagLib::ID3v2::FrameFactory::instance(),
1381-
TagLib::AudioProperties::Accurate));
1379+
tag.reset(new TagLib::MPEG::File(stream.get(), true,
1380+
TagLib::AudioProperties::Accurate,
1381+
TagLib::ID3v2::FrameFactory::instance()));
13821382
} else if (mime_type == "audio/mp4" ||
13831383
(mime_type == "audio/mpeg" &&
13841384
title.endsWith(".m4a", Qt::CaseInsensitive))) {
@@ -1398,9 +1398,9 @@ bool TagReader::ReadCloudFile(const QUrl& download_url, const QString& title,
13981398
TagLib::AudioProperties::Accurate));
13991399
} else if (mime_type == "application/x-flac" || mime_type == "audio/flac" ||
14001400
mime_type == "audio/x-flac") {
1401-
tag.reset(new TagLib::FLAC::File(stream.get(),
1402-
TagLib::ID3v2::FrameFactory::instance(),
1403-
true, TagLib::AudioProperties::Accurate));
1401+
tag.reset(new TagLib::FLAC::File(stream.get(), true,
1402+
TagLib::AudioProperties::Accurate,
1403+
TagLib::ID3v2::FrameFactory::instance()));
14041404
} else if (mime_type == "audio/x-ms-wma") {
14051405
tag.reset(new TagLib::ASF::File(stream.get(), true,
14061406
TagLib::AudioProperties::Accurate));
@@ -1431,7 +1431,7 @@ bool TagReader::ReadCloudFile(const QUrl& download_url, const QString& title,
14311431
song->set_type(cpb::tagreader::SongMetadata_Type_STREAM);
14321432

14331433
if (tag->audioProperties()) {
1434-
song->set_length_nanosec(tag->audioProperties()->length() * kNsecPerSec);
1434+
song->set_length_nanosec(tag->audioProperties()->lengthInMilliseconds() * kNsecPerMsec);
14351435
}
14361436
return true;
14371437
}

0 commit comments

Comments
 (0)