Fix bug setting wrong temp metadata and bug in pipeline

This commit is contained in:
Jonas Kvinge 2018-09-21 00:34:02 +02:00
parent a77dde7d3b
commit 0143617056
5 changed files with 11 additions and 8 deletions

View File

@ -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();
}

View File

@ -202,6 +202,7 @@ private:
};
struct SimpleMetaBundle {
QUrl url;
QString title;
QString artist;
QString album;

View File

@ -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);

View File

@ -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();

View File

@ -40,8 +40,7 @@
#include "internet/internetplaylistitem.h"
PlaylistItem::~PlaylistItem() {
}
PlaylistItem::~PlaylistItem() {}
PlaylistItem *PlaylistItem::NewFromSource(const Song::Source &source) {