Ignore useless metadata from gstreamer, and metadata that comes while the next track is preloading
This commit is contained in:
parent
910553b175
commit
3cc0ed361a
@ -288,6 +288,10 @@ void GstEngine::StartPreloading(const QUrl& url) {
|
||||
if (!preload_pipeline_)
|
||||
return;
|
||||
|
||||
// We don't want to get metadata messages before the track starts playing -
|
||||
// we reconnect this in GstEngine::Load
|
||||
disconnect(preload_pipeline_.get(), SIGNAL(MetadataFound(Engine::SimpleMetaBundle)), this, 0);
|
||||
|
||||
preloaded_url_ = url;
|
||||
preload_pipeline_->SetState(GST_STATE_PAUSED);
|
||||
}
|
||||
@ -302,6 +306,9 @@ bool GstEngine::Load(const QUrl& url, Engine::TrackChangeType change) {
|
||||
shared_ptr<GstEnginePipeline> pipeline;
|
||||
if (preload_pipeline_ && preloaded_url_ == url) {
|
||||
pipeline = preload_pipeline_;
|
||||
connect(preload_pipeline_.get(),
|
||||
SIGNAL(MetadataFound(Engine::SimpleMetaBundle)),
|
||||
SLOT(NewMetaData(Engine::SimpleMetaBundle)));
|
||||
} else {
|
||||
pipeline = CreatePipeline(url);
|
||||
if (!pipeline)
|
||||
|
@ -308,8 +308,8 @@ void Player::EngineMetadataReceived(const Engine::SimpleMetaBundle& bundle) {
|
||||
if (item == NULL)
|
||||
return;
|
||||
|
||||
Song song;
|
||||
song.InitFromSimpleMetaBundle(bundle);
|
||||
Song song = item->Metadata();
|
||||
song.MergeFromSimpleMetaBundle(bundle);
|
||||
|
||||
// Ignore useless metadata
|
||||
if (song.title().isEmpty() && song.artist().isEmpty())
|
||||
|
22
src/song.cpp
22
src/song.cpp
@ -342,19 +342,19 @@ void Song::InitFromLastFM(const lastfm::Track& track) {
|
||||
d->length_ = track.duration();
|
||||
}
|
||||
|
||||
void Song::InitFromSimpleMetaBundle(const Engine::SimpleMetaBundle &bundle) {
|
||||
void Song::MergeFromSimpleMetaBundle(const Engine::SimpleMetaBundle &bundle) {
|
||||
d->valid_ = true;
|
||||
|
||||
d->title_ = bundle.title;
|
||||
d->artist_ = bundle.artist;
|
||||
d->album_ = bundle.album;
|
||||
d->comment_ = bundle.comment;
|
||||
d->genre_ = bundle.genre;
|
||||
d->bitrate_ = bundle.bitrate.toInt();
|
||||
d->samplerate_ = bundle.samplerate.toInt();
|
||||
d->length_ = bundle.length.toInt();
|
||||
d->year_ = bundle.year.toInt();
|
||||
d->track_ = bundle.tracknr.toInt();
|
||||
if (!bundle.title.isEmpty()) d->title_ = bundle.title;
|
||||
if (!bundle.artist.isEmpty()) d->artist_ = bundle.artist;
|
||||
if (!bundle.album.isEmpty()) d->album_ = bundle.album;
|
||||
if (!bundle.comment.isEmpty()) d->comment_ = bundle.comment;
|
||||
if (!bundle.genre.isEmpty()) d->genre_ = bundle.genre;
|
||||
if (!bundle.bitrate.isEmpty()) d->bitrate_ = bundle.bitrate.toInt();
|
||||
if (!bundle.samplerate.isEmpty()) d->samplerate_ = bundle.samplerate.toInt();
|
||||
if (!bundle.length.isEmpty()) d->length_ = bundle.length.toInt();
|
||||
if (!bundle.year.isEmpty()) d->year_ = bundle.year.toInt();
|
||||
if (!bundle.tracknr.isEmpty()) d->track_ = bundle.tracknr.toInt();
|
||||
}
|
||||
|
||||
void Song::BindToQuery(QSqlQuery *query) const {
|
||||
|
@ -85,7 +85,7 @@ class Song {
|
||||
void InitFromFile(const QString& filename, int directory_id);
|
||||
void InitFromQuery(const QSqlQuery& query);
|
||||
void InitFromLastFM(const lastfm::Track& track);
|
||||
void InitFromSimpleMetaBundle(const Engine::SimpleMetaBundle& bundle);
|
||||
void MergeFromSimpleMetaBundle(const Engine::SimpleMetaBundle& bundle);
|
||||
|
||||
// Save
|
||||
void BindToQuery(QSqlQuery* query) const;
|
||||
|
Loading…
x
Reference in New Issue
Block a user