From 0143617056f5a03701679d29d111059bbfc48776 Mon Sep 17 00:00:00 2001 From: Jonas Kvinge Date: Fri, 21 Sep 2018 00:34:02 +0200 Subject: [PATCH] Fix bug setting wrong temp metadata and bug in pipeline --- src/core/player.cpp | 8 +++++--- src/engine/enginebase.h | 1 + src/engine/gstenginepipeline.cpp | 2 ++ src/playlist/playlist.cpp | 5 ++--- src/playlist/playlistitem.cpp | 3 +-- 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/core/player.cpp b/src/core/player.cpp index e09e82af..b1679393 100644 --- a/src/core/player.cpp +++ b/src/core/player.cpp @@ -239,7 +239,6 @@ void Player::HandleLoadResult(const UrlHandler::LoadResult &result) { } // If there was no length info in song's metadata, use the one provided by URL handler, if there is one if (item->Metadata().length_nanosec() <= 0 && result.length_nanosec_ != -1) { - Song song = item->Metadata(); song.set_length_nanosec(result.length_nanosec_); update = true; } @@ -547,10 +546,12 @@ void Player::SeekBackward() { } void Player::EngineMetadataReceived(const Engine::SimpleMetaBundle &bundle) { - + PlaylistItemPtr item = app_->playlist_manager()->active()->current_item(); if (!item) return; + if (item->Metadata().url() != bundle.url) return; + Engine::SimpleMetaBundle bundle_copy = bundle; // Maybe the metadata is from icycast and has "Artist - Title" shoved together in the title field. @@ -561,7 +562,8 @@ void Player::EngineMetadataReceived(const Engine::SimpleMetaBundle &bundle) { if (space_dash_pos != -1) { bundle_copy.artist = bundle_copy.title.left(space_dash_pos).trimmed(); bundle_copy.title = bundle_copy.title.mid(space_dash_pos + 3).trimmed(); - } else { + } + else { bundle_copy.artist = bundle_copy.title.left(dash_pos).trimmed(); bundle_copy.title = bundle_copy.title.mid(dash_pos + 1).trimmed(); } diff --git a/src/engine/enginebase.h b/src/engine/enginebase.h index 25405794..2ec95823 100644 --- a/src/engine/enginebase.h +++ b/src/engine/enginebase.h @@ -202,6 +202,7 @@ private: }; struct SimpleMetaBundle { + QUrl url; QString title; QString artist; QString album; diff --git a/src/engine/gstenginepipeline.cpp b/src/engine/gstenginepipeline.cpp index 7fa2b364..d329a72d 100644 --- a/src/engine/gstenginepipeline.cpp +++ b/src/engine/gstenginepipeline.cpp @@ -373,6 +373,7 @@ bool GstEnginePipeline::InitFromString(const QString &pipeline) { bool GstEnginePipeline::InitFromUrl(const QByteArray &url, qint64 end_nanosec) { + url_ = url; end_offset_nanosec_ = end_nanosec; pipeline_ = engine_->CreateElement("playbin"); @@ -579,6 +580,7 @@ void GstEnginePipeline::TagMessageReceived(GstMessage *msg) { gst_message_parse_tag(msg, &taglist); Engine::SimpleMetaBundle bundle; + bundle.url = QUrl(QString(url_)); bundle.title = ParseTag(taglist, GST_TAG_TITLE); bundle.artist = ParseTag(taglist, GST_TAG_ARTIST); bundle.comment = ParseTag(taglist, GST_TAG_COMMENT); diff --git a/src/playlist/playlist.cpp b/src/playlist/playlist.cpp index 339694a4..69634b89 100644 --- a/src/playlist/playlist.cpp +++ b/src/playlist/playlist.cpp @@ -1456,15 +1456,14 @@ void Playlist::StopAfter(int row) { void Playlist::SetStreamMetadata(const QUrl &url, const Song &song) { - //qLog(Debug) << "Setting metadata for" << url << "to" << song.artist() << song.title(); - if (!current_item()) return; - if (current_item()->Url() != url) return; // Don't update the metadata if it's only a minor change from before if (current_item()->Metadata().artist() == song.artist() && current_item()->Metadata().title() == song.title()) return; + //qLog(Debug) << "Setting metadata for" << url << "to" << song.artist() << song.title(); + current_item()->SetTemporaryMetadata(song); InformOfCurrentSongChange(); diff --git a/src/playlist/playlistitem.cpp b/src/playlist/playlistitem.cpp index 5782f746..749472a8 100644 --- a/src/playlist/playlistitem.cpp +++ b/src/playlist/playlistitem.cpp @@ -40,8 +40,7 @@ #include "internet/internetplaylistitem.h" -PlaylistItem::~PlaylistItem() { -} +PlaylistItem::~PlaylistItem() {} PlaylistItem *PlaylistItem::NewFromSource(const Song::Source &source) {