From 0af6278a4515dcd70d723042e00345faec8cccae Mon Sep 17 00:00:00 2001 From: jpd002 Date: Sat, 24 May 2014 05:09:35 +0000 Subject: [PATCH] Moved title attribution logic from PlaylistDiscoveryService to Playlist to make the titles consistent. git-svn-id: http://svn.purei.org/purei/trunk@1307 b36208d7-6611-0410-8bec-b1987f11c4a2 --- tools/PsfPlayer/Source/Playlist.cpp | 11 ++++++++-- .../Source/PlaylistDiscoveryService.cpp | 20 ++----------------- .../Source/PlaylistDiscoveryService.h | 3 +-- 3 files changed, 12 insertions(+), 22 deletions(-) diff --git a/tools/PsfPlayer/Source/Playlist.cpp b/tools/PsfPlayer/Source/Playlist.cpp index f7b063fa..4387c1c7 100644 --- a/tools/PsfPlayer/Source/Playlist.cpp +++ b/tools/PsfPlayer/Source/Playlist.cpp @@ -80,8 +80,15 @@ bool CPlaylist::IsLoadableExtension(const std::string& extension) void CPlaylist::PopulateItemFromTags(ITEM& item, const CPsfTags& tags) { - item.title = tags.GetTagValue("title"); - item.length = CPsfTags::ConvertTimeString(tags.GetTagValue("length").c_str()); + if(tags.HasTag("title")) + { + item.title = tags.GetTagValue("title"); + } + else + { + item.title = item.path; + } + item.length = CPsfTags::ConvertTimeString(tags.GetTagValue("length").c_str()); } unsigned int CPlaylist::InsertArchive(const std::wstring& path) diff --git a/tools/PsfPlayer/Source/PlaylistDiscoveryService.cpp b/tools/PsfPlayer/Source/PlaylistDiscoveryService.cpp index 71ea1ed4..24cadfd6 100644 --- a/tools/PsfPlayer/Source/PlaylistDiscoveryService.cpp +++ b/tools/PsfPlayer/Source/PlaylistDiscoveryService.cpp @@ -66,8 +66,7 @@ void CPlaylistDiscoveryService::ProcessPendingItems(CPlaylist& playlist) if(itemIdx != -1) { CPlaylist::ITEM item = playlist.GetItem(itemIdx); - item.title = result.title; - item.length = result.length; + CPlaylist::PopulateItemFromTags(item, result.tags); playlist.UpdateItem(itemIdx, item); } } @@ -95,22 +94,7 @@ void CPlaylistDiscoveryService::ThreadProc() RESULT result; result.runId = command.runId; result.itemId = command.itemId; - result.length = 0; - - if(tags.HasTag("title")) - { - result.title = tags.GetTagValue("title"); - } - else - { - result.title = command.filePath.GetWidePath(); - } - - if(tags.HasTag("length")) - { - result.length = tags.ConvertTimeString(tags.GetTagValue("length").c_str()); - } - + result.tags = tags; pendingResults.push_back(result); } catch(...) diff --git a/tools/PsfPlayer/Source/PlaylistDiscoveryService.h b/tools/PsfPlayer/Source/PlaylistDiscoveryService.h index b1994d38..5f586db7 100644 --- a/tools/PsfPlayer/Source/PlaylistDiscoveryService.h +++ b/tools/PsfPlayer/Source/PlaylistDiscoveryService.h @@ -33,8 +33,7 @@ private: { unsigned int runId; unsigned int itemId; - std::wstring title; - double length; + CPsfTags tags; }; typedef std::deque CommandQueue;