From 1c92696b40b42c291ab2679e09971a6b865709d8 Mon Sep 17 00:00:00 2001 From: "Chris \"Koying\" Browet" Date: Sun, 27 Mar 2016 16:36:42 +0200 Subject: [PATCH] FIX: speedup thumb loading --- xbmc/BackgroundInfoLoader.cpp | 25 ++----------------------- xbmc/ThumbLoader.cpp | 3 ++- xbmc/music/MusicInfoLoader.cpp | 5 +++-- xbmc/music/MusicThumbLoader.cpp | 3 ++- xbmc/pictures/PictureInfoLoader.cpp | 3 ++- xbmc/pictures/PictureThumbLoader.cpp | 3 ++- xbmc/video/VideoThumbLoader.cpp | 5 +++-- 7 files changed, 16 insertions(+), 31 deletions(-) diff --git a/xbmc/BackgroundInfoLoader.cpp b/xbmc/BackgroundInfoLoader.cpp index 4b765fa651e3c..da8deeb45db2a 100644 --- a/xbmc/BackgroundInfoLoader.cpp +++ b/xbmc/BackgroundInfoLoader.cpp @@ -46,7 +46,6 @@ void CBackgroundInfoLoader::Run() { OnLoaderStart(); - // Stage 1: All "fast" stuff we have already cached for (std::vector::const_iterator iter = m_vecItems.begin(); iter != m_vecItems.end(); ++iter) { CFileItemPtr pItem = *iter; @@ -57,32 +56,12 @@ void CBackgroundInfoLoader::Run() try { - if (LoadItemCached(pItem.get()) && m_pObserver) + if (LoadItem(pItem.get()) && m_pObserver) m_pObserver->OnItemLoaded(pItem.get()); } catch (...) { - CLog::Log(LOGERROR, "CBackgroundInfoLoader::LoadItemCached - Unhandled exception for item %s", CURL::GetRedacted(pItem->GetPath()).c_str()); - } - } - - // Stage 2: All "slow" stuff that we need to lookup - for (std::vector::const_iterator iter = m_vecItems.begin(); iter != m_vecItems.end(); ++iter) - { - CFileItemPtr pItem = *iter; - - // Ask the callback if we should abort - if ((m_pProgressCallback && m_pProgressCallback->Abort()) || m_bStop) - break; - - try - { - if (LoadItemLookup(pItem.get()) && m_pObserver) - m_pObserver->OnItemLoaded(pItem.get()); - } - catch (...) - { - CLog::Log(LOGERROR, "CBackgroundInfoLoader::LoadItemLookup - Unhandled exception for item %s", CURL::GetRedacted(pItem->GetPath()).c_str()); + CLog::Log(LOGERROR, "CBackgroundInfoLoader::LoadItem - Unhandled exception for item %s", CURL::GetRedacted(pItem->GetPath()).c_str()); } } } diff --git a/xbmc/ThumbLoader.cpp b/xbmc/ThumbLoader.cpp index 719c8800c1017..fdbdc5007eb94 100644 --- a/xbmc/ThumbLoader.cpp +++ b/xbmc/ThumbLoader.cpp @@ -77,7 +77,8 @@ CProgramThumbLoader::~CProgramThumbLoader() bool CProgramThumbLoader::LoadItem(CFileItem *pItem) { bool result = LoadItemCached(pItem); - result |= LoadItemLookup(pItem); + if (!result) + result |= LoadItemLookup(pItem); return result; } diff --git a/xbmc/music/MusicInfoLoader.cpp b/xbmc/music/MusicInfoLoader.cpp index a6a9e893aa916..07c87f82357db 100644 --- a/xbmc/music/MusicInfoLoader.cpp +++ b/xbmc/music/MusicInfoLoader.cpp @@ -127,7 +127,8 @@ bool CMusicInfoLoader::LoadAdditionalTagInfo(CFileItem* pItem) bool CMusicInfoLoader::LoadItem(CFileItem* pItem) { bool result = LoadItemCached(pItem); - result |= LoadItemLookup(pItem); + if (!result) + result |= LoadItemLookup(pItem); return result; } @@ -140,7 +141,7 @@ bool CMusicInfoLoader::LoadItemCached(CFileItem* pItem) // Get thumb for item m_thumbLoader->LoadItem(pItem); - return true; + return pItem->HasMusicInfoTag() && pItem->GetMusicInfoTag()->Loaded(); } bool CMusicInfoLoader::LoadItemLookup(CFileItem* pItem) diff --git a/xbmc/music/MusicThumbLoader.cpp b/xbmc/music/MusicThumbLoader.cpp index 8df7cd3d42d1d..6440a1999f4fd 100644 --- a/xbmc/music/MusicThumbLoader.cpp +++ b/xbmc/music/MusicThumbLoader.cpp @@ -58,7 +58,8 @@ void CMusicThumbLoader::OnLoaderFinish() bool CMusicThumbLoader::LoadItem(CFileItem* pItem) { bool result = LoadItemCached(pItem); - result |= LoadItemLookup(pItem); + if (!result) + result |= LoadItemLookup(pItem); return result; } diff --git a/xbmc/pictures/PictureInfoLoader.cpp b/xbmc/pictures/PictureInfoLoader.cpp index dd3347277c75c..3d87693a747f2 100644 --- a/xbmc/pictures/PictureInfoLoader.cpp +++ b/xbmc/pictures/PictureInfoLoader.cpp @@ -51,7 +51,8 @@ void CPictureInfoLoader::OnLoaderStart() bool CPictureInfoLoader::LoadItem(CFileItem* pItem) { bool result = LoadItemCached(pItem); - result |= LoadItemLookup(pItem); + if (!result) + result |= LoadItemLookup(pItem); return result; } diff --git a/xbmc/pictures/PictureThumbLoader.cpp b/xbmc/pictures/PictureThumbLoader.cpp index 6d02ae2e8d92c..16f6072a77a12 100644 --- a/xbmc/pictures/PictureThumbLoader.cpp +++ b/xbmc/pictures/PictureThumbLoader.cpp @@ -54,7 +54,8 @@ void CPictureThumbLoader::OnLoaderFinish() bool CPictureThumbLoader::LoadItem(CFileItem* pItem) { bool result = LoadItemCached(pItem); - result |= LoadItemLookup(pItem); + if (!result) + result |= LoadItemLookup(pItem); return result; } diff --git a/xbmc/video/VideoThumbLoader.cpp b/xbmc/video/VideoThumbLoader.cpp index d538598078029..fae68021808e4 100644 --- a/xbmc/video/VideoThumbLoader.cpp +++ b/xbmc/video/VideoThumbLoader.cpp @@ -263,7 +263,8 @@ std::vector CVideoThumbLoader::GetArtTypes(const std::string &type) bool CVideoThumbLoader::LoadItem(CFileItem* pItem) { bool result = LoadItemCached(pItem); - result |= LoadItemLookup(pItem); + if (!result) + result |= LoadItemLookup(pItem); return result; } @@ -321,7 +322,7 @@ bool CVideoThumbLoader::LoadItemCached(CFileItem* pItem) m_videoDatabase->Close(); - return true; + return pItem->HasArt("thumb"); } bool CVideoThumbLoader::LoadItemLookup(CFileItem* pItem)