Skip to content

Commit

Permalink
FIX: speedup thumb loading
Browse files Browse the repository at this point in the history
  • Loading branch information
koying authored and popcornmix committed Apr 2, 2016
1 parent 1d53b29 commit 1c92696
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 31 deletions.
25 changes: 2 additions & 23 deletions xbmc/BackgroundInfoLoader.cpp
Expand Up @@ -46,7 +46,6 @@ void CBackgroundInfoLoader::Run()
{
OnLoaderStart();

// Stage 1: All "fast" stuff we have already cached
for (std::vector<CFileItemPtr>::const_iterator iter = m_vecItems.begin(); iter != m_vecItems.end(); ++iter)
{
CFileItemPtr pItem = *iter;
Expand All @@ -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<CFileItemPtr>::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());
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion xbmc/ThumbLoader.cpp
Expand Up @@ -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;
}
Expand Down
5 changes: 3 additions & 2 deletions xbmc/music/MusicInfoLoader.cpp
Expand Up @@ -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;
}
Expand All @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion xbmc/music/MusicThumbLoader.cpp
Expand Up @@ -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;
}
Expand Down
3 changes: 2 additions & 1 deletion xbmc/pictures/PictureInfoLoader.cpp
Expand Up @@ -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;
}
Expand Down
3 changes: 2 additions & 1 deletion xbmc/pictures/PictureThumbLoader.cpp
Expand Up @@ -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;
}
Expand Down
5 changes: 3 additions & 2 deletions xbmc/video/VideoThumbLoader.cpp
Expand Up @@ -263,7 +263,8 @@ std::vector<std::string> 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;
}
Expand Down Expand Up @@ -321,7 +322,7 @@ bool CVideoThumbLoader::LoadItemCached(CFileItem* pItem)

m_videoDatabase->Close();

return true;
return pItem->HasArt("thumb");
}

bool CVideoThumbLoader::LoadItemLookup(CFileItem* pItem)
Expand Down

0 comments on commit 1c92696

Please sign in to comment.