1
0
mirror of https://github.com/clementine-player/Clementine synced 2025-01-31 03:27:40 +01:00

Load local tags asynchronously in SongLoader.

This commit is contained in:
David Sansome 2013-02-17 18:19:05 +11:00
parent 4acafb4930
commit 115964d1b4
2 changed files with 26 additions and 9 deletions

View File

@ -276,30 +276,45 @@ SongLoader::Result SongLoader::LoadLocal(const QString& filename) {
} else {
QString matching_cue = filename.section('.', 0, -2) + ".cue";
// it's a cue - create virtual tracks
if(QFile::exists(matching_cue)) {
if (QFile::exists(matching_cue)) {
// it's a cue - create virtual tracks
QFile cue(matching_cue);
cue.open(QIODevice::ReadOnly);
song_list = cue_parser_->Load(&cue, matching_cue, QDir(filename.section('/', 0, -2)));
// it's a normal media file
} else {
Song song;
TagReaderClient::Instance()->ReadFileBlocking(filename, &song);
song_list << song;
// it's a normal media file, load it asynchronously.
TagReaderReply* reply = TagReaderClient::Instance()->ReadFile(filename);
NewClosure(reply, SIGNAL(Finished(bool)),
this, SLOT(LocalFileLoaded(TagReaderReply*)),
reply);
return WillLoadAsync;
}
}
foreach (const Song& song, song_list) {
if (song.is_valid())
if (song.is_valid()) {
songs_ << song;
}
}
return Success;
}
void SongLoader::LocalFileLoaded(TagReaderReply* reply) {
reply->deleteLater();
Song song;
song.InitFromProtobuf(reply->message().read_file_response().metadata());
if (song.is_valid()) {
songs_ << song;
}
emit LoadFinished(true);
}
void SongLoader::EffectiveSongsLoad() {
for (int i = 0; i < songs_.size(); i++) {
EffectiveSongLoad(&songs_[i]);

View File

@ -23,6 +23,7 @@
#include <QUrl>
#include "song.h"
#include "core/tagreaderclient.h"
#include "musicbrainz/musicbrainzclient.h"
#include <boost/shared_ptr.hpp>
@ -76,6 +77,7 @@ private slots:
void StopTypefind();
void AudioCDTagsLoaded(const QString& artist, const QString& album,
const MusicBrainzClient::ResultList& results);
void LocalFileLoaded(TagReaderReply* reply);
private:
enum State {