Permalink
Browse files

[cleanup] remove old thumb caching code as no longer used

  • Loading branch information...
1 parent 7e0a095 commit 3ae889107a2afe40fa1c396e4531738ddd6df70e Jonathan Marshall committed Jun 30, 2012
View
183 xbmc/FileItem.cpp
@@ -55,7 +55,6 @@
#include "utils/log.h"
#include "utils/Variant.h"
#include "music/karaoke/karaokelyricsfactory.h"
-#include "ThumbnailCache.h"
#include "utils/Mime.h"
#include "utils/CharsetConverter.h"
@@ -1008,31 +1007,6 @@ void CFileItem::FillInDefaultIcon()
}
}
-CStdString CFileItem::GetCachedArtistThumb() const
-{
- return CThumbnailCache::GetArtistThumb(*this);
-}
-
-void CFileItem::SetCachedArtistThumb()
-{
- CStdString thumb(GetCachedArtistThumb());
- if (CFile::Exists(thumb))
- {
- // found it, we are finished.
- SetThumbnailImage(thumb);
- }
-}
-
-// set the album thumb for a file or folder
-void CFileItem::SetMusicThumb(bool alwaysCheckRemote /* = true */)
-{
- if (HasThumbnail()) return;
-
- SetCachedMusicThumb();
- if (!HasThumbnail())
- SetUserMusicThumb(alwaysCheckRemote);
-}
-
void CFileItem::RemoveExtension()
{
if (m_bIsFolder)
@@ -1824,21 +1798,6 @@ void CFileItemList::FillInDefaultIcons()
}
}
-void CFileItemList::SetMusicThumbs()
-{
- CSingleLock lock(m_lock);
- //cache thumbnails directory
- g_directoryCache.InitMusicThumbCache();
-
- for (int i = 0; i < (int)m_items.size(); ++i)
- {
- CFileItemPtr pItem = m_items[i];
- pItem->SetMusicThumb();
- }
-
- g_directoryCache.ClearMusicThumbCache();
-}
-
int CFileItemList::GetFolderCount() const
{
CSingleLock lock(m_lock);
@@ -2441,84 +2400,6 @@ bool CFileItemList::AlwaysCache() const
return false;
}
-void CFileItemList::SetCachedMusicThumbs()
-{
- CSingleLock lock(m_lock);
- // TODO: Investigate caching time to see if it speeds things up
- for (unsigned int i = 0; i < m_items.size(); ++i)
- {
- CFileItemPtr pItem = m_items[i];
- pItem->SetCachedMusicThumb();
- }
-}
-
-void CFileItem::SetCachedMusicThumb()
-{
- // if it already has a thumbnail, then return
- if (HasThumbnail() || m_bIsShareOrDrive) return ;
-
- // streams do not have thumbnails
- if (IsInternetStream()) return ;
-
- // music db items already have thumbs or there is no thumb available
- if (IsMusicDb()) return;
-
- // ignore the parent dir items
- if (IsParentFolder()) return;
-
- CStdString cachedThumb(GetPreviouslyCachedMusicThumb());
- if (!cachedThumb.IsEmpty())
- SetThumbnailImage(cachedThumb);
- // SetIconImage(cachedThumb);
-}
-
-CStdString CFileItem::GetPreviouslyCachedMusicThumb() const
-{
- // look if an album thumb is available,
- // could be any file with tags loaded or
- // a directory in album window
- CStdString strAlbum, strArtist;
- if (HasMusicInfoTag() && m_musicInfoTag->Loaded())
- {
- strAlbum = m_musicInfoTag->GetAlbum();
- if (!m_musicInfoTag->GetAlbumArtist().empty())
- strArtist = StringUtils::Join(m_musicInfoTag->GetAlbumArtist(), g_advancedSettings.m_musicItemSeparator);
- else
- strArtist = StringUtils::Join(m_musicInfoTag->GetArtist(), g_advancedSettings.m_musicItemSeparator);
- }
- if (!strAlbum.IsEmpty() && !strArtist.IsEmpty())
- {
- // try permanent album thumb using "album name + artist name"
- CStdString thumb(CThumbnailCache::GetAlbumThumb(strAlbum, strArtist));
- if (CFile::Exists(thumb))
- return thumb;
- }
-
- // if a file, try to find a cached filename.tbn
- if (!m_bIsFolder)
- {
- // look for locally cached tbn
- CStdString thumb(CThumbnailCache::GetMusicThumb(m_strPath));
- if (CFile::Exists(thumb))
- return thumb;
- }
-
- // try and find a cached folder thumb (folder.jpg or folder.tbn)
- CStdString strPath;
- if (!m_bIsFolder)
- URIUtils::GetDirectory(m_strPath, strPath);
- else
- strPath = m_strPath;
- // music thumbs are cached without slash at end
- URIUtils::RemoveSlashAtEnd(strPath);
-
- CStdString thumb(CThumbnailCache::GetMusicThumb(strPath));
- if (CFile::Exists(thumb))
- return thumb;
-
- return "";
-}
-
CStdString CFileItem::GetUserMusicThumb(bool alwaysCheckRemote /* = false */) const
{
if (m_strPath.IsEmpty()
@@ -2555,19 +2436,6 @@ CStdString CFileItem::GetUserMusicThumb(bool alwaysCheckRemote /* = false */) co
return "";
}
-void CFileItem::SetUserMusicThumb(bool alwaysCheckRemote /* = false */)
-{
- // caches as the local thumb
- CStdString thumb(GetUserMusicThumb(alwaysCheckRemote));
- if (!thumb.IsEmpty())
- {
- CStdString cachedThumb(CThumbnailCache::GetMusicThumb(m_strPath));
- CPicture::CreateThumbnail(thumb, cachedThumb);
- }
-
- SetCachedMusicThumb();
-}
-
// Gets the .tbn filename from a file or folder name.
// <filename>.ext -> <filename>.tbn
// <foldername>/ -> <foldername>.tbn
@@ -2781,20 +2649,6 @@ bool CFileItem::testGetBaseMoviePath()
}
#endif
-bool CFileItem::CacheLocalFanart() const
-{
- // first check for an already cached fanart image
- CStdString cachedFanart(GetCachedFanart());
- if (CFile::Exists(cachedFanart))
- return true;
-
- // we don't have a cached image, so let's see if the user has a local image, and cache it if so
- CStdString localFanart(GetLocalFanart());
- if (!localFanart.IsEmpty())
- return CPicture::CacheFanart(localFanart, cachedFanart);
- return false;
-}
-
CStdString CFileItem::GetLocalFanart() const
{
if (IsVideoDb())
@@ -2895,43 +2749,6 @@ CStdString CFileItem::GetLocalMetadataPath() const
return parent;
}
-CStdString CFileItem::GetCachedFanart() const
-{
- return CThumbnailCache::GetFanart(*this);
-}
-
-CStdString CFileItem::GetCachedThumb(const CStdString &path, const CStdString &path2, bool split)
-{
- return CThumbnailCache::GetThumb(path, path2, split);
-}
-
-/*void CFileItem::SetThumb()
-{
- // we need to know the type of file at this point
- // as differing views have differing inheritance rules for thumbs:
-
- // Videos:
- // Folders only use <foldername>/folder.jpg or <foldername>.tbn
- // Files use <filename>.tbn
- // * Thumbs are cached from here using file or folder path
-
- // Music:
- // Folders only use <foldername>/folder.jpg or <foldername>.tbn
- // Files use <filename>.tbn or the album/path cached thumb or inherit from the folder
- // * Thumbs are cached from here using file or folder path
-
- // Programs:
- // Folders only use <foldername>/folder.jpg or <foldername>.tbn
- // Files use <filename>.tbn or the embedded xbe. Shortcuts have the additional step of the <thumbnail> tag to check
- // * Thumbs are cached from here using file or folder path
-
- // Pictures:
- // Folders use <foldername>/folder.jpg or <foldername>.tbn, or auto-generated from 4 images in the folder
- // Files use <filename>.tbn or a resized version of the picture
- // * Thumbs are cached from here using file or folder path
-
-}*/
-
bool CFileItem::LoadMusicTag()
{
// not audio
View
33 xbmc/FileItem.h
@@ -153,7 +153,6 @@ class CFileItem :
void RemoveExtension();
void CleanString();
void FillInDefaultIcon();
- void SetMusicThumb(bool alwaysCheckRemote = false);
void SetFileSizeLabel();
virtual void SetLabel(const CStdString &strLabel);
CURL GetAsUrl() const;
@@ -200,33 +199,13 @@ class CFileItem :
CPictureInfoTag* GetPictureInfoTag();
- // Gets the cached thumb filename (no existence checks)
- CStdString GetCachedArtistThumb() const;
- /*!
- \brief Get the cached fanart path for this item if it exists
- \return path to the cached fanart for this item, or empty if none exists
- \sa CacheLocalFanart, GetLocalFanart
- */
- CStdString GetCachedFanart() const;
- static CStdString GetCachedThumb(const CStdString &path, const CStdString& strPath2, bool split=false);
-
- /*!
- \brief Cache a copy of the local fanart for this item if we don't already have an image cached
- \return true if we already have cached fanart or if the caching was successful, false if no image is cached.
- \sa GetLocalFanart, GetCachedFanart
- */
- bool CacheLocalFanart() const;
/*!
\brief Get the local fanart for this item if it exists
\return path to the local fanart for this item, or empty if none exists
- \sa CacheLocalFanart, GetCachedFanart
+ \sa GetFolderThumb, GetTBNFile
*/
CStdString GetLocalFanart() const;
- // Sets the cached thumb for the item if it exists
- void SetCachedArtistThumb();
- void SetCachedMusicThumb();
-
// Gets the .tbn file associated with this item
CStdString GetTBNFile() const;
// Gets the folder image associated with this item (defaults to folder.jpg)
@@ -251,9 +230,6 @@ class CFileItem :
CStdString GetUserVideoThumb() const;
CStdString GetUserMusicThumb(bool alwaysCheckRemote = false) const;
- // Caches the user thumb and assigns it to the item
- void SetUserMusicThumb(bool alwaysCheckRemote = false);
-
/*! \brief Get the path where we expect local metadata to reside.
For a folder, this is just the existing path (eg tvshow folder)
For a file, this is the parent path, with exceptions made for VIDEO_TS and BDMV files
@@ -296,11 +272,7 @@ class CFileItem :
bool IsSamePath(const CFileItem *item) const;
bool IsAlbum() const;
-private:
- // Gets the previously cached thumb file (with existence checks)
- CStdString GetPreviouslyCachedMusicThumb() const;
-public:
bool m_bIsShareOrDrive; ///< is this a root share/drive
int m_iDriveType; ///< If \e m_bIsShareOrDrive is \e true, use to get the share type. Types see: CMediaSource::m_iDriveType
CDateTime m_dateTime; ///< file creation date & time
@@ -405,7 +377,6 @@ class CFileItemList : public CFileItem
void Reserve(int iCount);
void Sort(SORT_METHOD sortMethod, SortOrder sortOrder);
void Randomize();
- void SetMusicThumbs();
void FillInDefaultIcons();
int GetFolderCount() const;
int GetFileCount() const;
@@ -464,8 +435,6 @@ class CFileItemList : public CFileItem
void RemoveDiscCache(int windowID = 0) const;
bool AlwaysCache() const;
- void SetCachedMusicThumbs();
-
void Swap(unsigned int item1, unsigned int item2);
/*! \brief Update an item in the item list
View
162 xbmc/ThumbnailCache.cpp
@@ -60,165 +60,3 @@ CThumbnailCache* CThumbnailCache::GetThumbnailCache()
return m_pCacheInstance;
}
-
-bool CThumbnailCache::ThumbExists(const CStdString& strFileName, bool bAddCache /*=false*/)
-{
- CSingleLock lock (m_cs);
-
- if (strFileName.size() == 0) return false;
- map<CStdString, bool>::iterator it;
- it = m_Cache.find(strFileName);
- if (it != m_Cache.end())
- return it->second;
-
- bool bExists = CFile::Exists(strFileName);
-
- if (bAddCache)
- Add(strFileName, bExists);
- return bExists;
-}
-
-bool CThumbnailCache::IsCached(const CStdString& strFileName)
-{
- CSingleLock lock (m_cs);
-
- map<CStdString, bool>::iterator it;
- it = m_Cache.find(strFileName);
- return it != m_Cache.end();
-}
-
-void CThumbnailCache::Clear()
-{
- CSingleLock lock (m_cs);
-
- if (m_pCacheInstance != NULL)
- {
- m_Cache.erase(m_Cache.begin(), m_Cache.end());
- delete m_pCacheInstance;
- }
-
- m_pCacheInstance = NULL;
-}
-
-void CThumbnailCache::Add(const CStdString& strFileName, bool bExists)
-{
- CSingleLock lock (m_cs);
-
- map<CStdString, bool>::iterator it;
- it = m_Cache.find(strFileName);
- if (it != m_Cache.end())
- it->second = bExists;
- else
- m_Cache.insert(pair<CStdString, bool>(strFileName, bExists));
-}
-
-CStdString CThumbnailCache::GetAlbumThumb(const CFileItem &item)
-{
- return GetAlbumThumb(item.GetMusicInfoTag());
-}
-
-CStdString CThumbnailCache::GetAlbumThumb(const CMusicInfoTag *musicInfo)
-{
- if (!musicInfo)
- return CStdString();
-
- return GetAlbumThumb(musicInfo->GetAlbum(), StringUtils::Join(!musicInfo->GetAlbumArtist().empty() ? musicInfo->GetAlbumArtist() : musicInfo->GetArtist(), g_advancedSettings.m_musicItemSeparator));
-}
-
-CStdString CThumbnailCache::GetAlbumThumb(const CAlbum &album)
-{
- return GetAlbumThumb(album.strAlbum, StringUtils::Join(album.artist, g_advancedSettings.m_musicItemSeparator));
-}
-
-CStdString CThumbnailCache::GetAlbumThumb(const CStdString& album, const CStdString& artist)
-{
- if (album.IsEmpty())
- return GetMusicThumb("unknown" + artist);
- if (artist.IsEmpty())
- return GetMusicThumb(album + "unknown");
- return GetMusicThumb(album + artist);
-}
-
-CStdString CThumbnailCache::GetArtistThumb(const CFileItem &item)
-{
- return GetArtistThumb(item.GetLabel());
-}
-
-CStdString CThumbnailCache::GetArtistThumb(const CArtist &artist)
-{
- return GetArtistThumb(artist.strArtist);
-}
-
-CStdString CThumbnailCache::GetArtistThumb(const CStdString &label)
-{
- return GetThumb("artist" + label, g_settings.GetMusicArtistThumbFolder());
-}
-
-CStdString CThumbnailCache::GetFanart(const CFileItem &item)
-{
- // get the locally cached thumb
- if (item.IsVideoDb() || (item.HasVideoInfoTag() && !item.GetVideoInfoTag()->IsEmpty()))
- {
- if (!item.HasVideoInfoTag())
- return "";
- if (!item.GetVideoInfoTag()->m_artist.empty())
- return GetThumb(StringUtils::Join(item.GetVideoInfoTag()->m_artist, g_advancedSettings.m_videoItemSeparator),g_settings.GetMusicFanartFolder());
- if (!item.m_bIsFolder && !item.GetVideoInfoTag()->m_strShowTitle.IsEmpty())
- {
- CStdString showPath;
- if (!item.GetVideoInfoTag()->m_strShowPath.IsEmpty())
- showPath = item.GetVideoInfoTag()->m_strShowPath;
- else
- {
- CVideoDatabase database;
- database.Open();
- int iShowId = item.GetVideoInfoTag()->m_iIdShow;
- if (iShowId <= 0)
- iShowId = database.GetTvShowId(item.GetVideoInfoTag()->m_strPath);
- CStdString showPath;
- database.GetFilePathById(iShowId,showPath,VIDEODB_CONTENT_TVSHOWS);
- }
- return GetThumb(showPath,g_settings.GetVideoFanartFolder());
- }
- CStdString path = item.GetVideoInfoTag()->GetPath();
- if (path.empty())
- return "";
- return GetThumb(path,g_settings.GetVideoFanartFolder());
- }
- if (item.HasMusicInfoTag())
- return GetThumb(StringUtils::Join(item.GetMusicInfoTag()->GetArtist(), g_advancedSettings.m_musicItemSeparator),g_settings.GetMusicFanartFolder());
-
- return GetThumb(item.GetPath(),g_settings.GetVideoFanartFolder());
-}
-
-CStdString CThumbnailCache::GetThumb(const CStdString &path, const CStdString &path2, bool split /* = false */)
-{
- // get the locally cached thumb
- Crc32 crc;
- crc.ComputeFromLowerCase(path);
-
- CStdString thumb;
- if (split)
- {
- CStdString hex;
- hex.Format("%08x", (__int32)crc);
- thumb.Format("%c\\%08x.tbn", hex[0], (unsigned __int32)crc);
- }
- else
- thumb.Format("%08x.tbn", (unsigned __int32)crc);
-
- return URIUtils::AddFileToFolder(path2, thumb);
-}
-
-CStdString CThumbnailCache::GetMusicThumb(const CStdString& path)
-{
- Crc32 crc;
- CStdString noSlashPath(path);
- URIUtils::RemoveSlashAtEnd(noSlashPath);
- crc.ComputeFromLowerCase(noSlashPath);
- CStdString hex;
- hex.Format("%08x", (unsigned __int32) crc);
- CStdString thumb;
- thumb.Format("%c/%s.tbn", hex[0], hex.c_str());
- return URIUtils::AddFileToFolder(g_settings.GetMusicThumbFolder(), thumb);
-}
View
16 xbmc/ThumbnailCache.h
@@ -42,26 +42,10 @@ class CThumbnailCache
virtual ~CThumbnailCache();
static CThumbnailCache* GetThumbnailCache();
- bool ThumbExists(const CStdString& strFileName, bool bAddCache = false);
- void Add(const CStdString& strFileName, bool bExists);
- void Clear();
- bool IsCached(const CStdString& strFileName);
- static CStdString GetMusicThumb(const CStdString &path);
- static CStdString GetAlbumThumb(const CFileItem &item);
- static CStdString GetAlbumThumb(const MUSIC_INFO::CMusicInfoTag *musicInfo);
- static CStdString GetAlbumThumb(const CAlbum &album);
- static CStdString GetAlbumThumb(const CStdString &album, const CStdString &artist);
- static CStdString GetArtistThumb(const CArtist &artist);
- static CStdString GetArtistThumb(const CFileItem &item);
- static CStdString GetArtistThumb(const CStdString &label);
- static CStdString GetFanart(const CFileItem &item);
- static CStdString GetThumb(const CStdString &path, const CStdString &path2, bool split = false);
protected:
static CThumbnailCache* m_pCacheInstance;
- std::map<CStdString, bool> m_Cache;
-
static CCriticalSection m_cs;
};
View
21 xbmc/Util.cpp
@@ -48,7 +48,6 @@
#include "filesystem/DirectoryCache.h"
#include "filesystem/SpecialProtocol.h"
#include "filesystem/RSSDirectory.h"
-#include "ThumbnailCache.h"
#ifdef HAS_FILESYSTEM_RAR
#include "filesystem/RarManager.h"
#endif
@@ -771,26 +770,6 @@ int64_t CUtil::ToInt64(uint32_t high, uint32_t low)
return n;
}
-bool CUtil::ThumbExists(const CStdString& strFileName, bool bAddCache)
-{
- return CThumbnailCache::GetThumbnailCache()->ThumbExists(strFileName, bAddCache);
-}
-
-void CUtil::ThumbCacheAdd(const CStdString& strFileName, bool bFileExists)
-{
- CThumbnailCache::GetThumbnailCache()->Add(strFileName, bFileExists);
-}
-
-void CUtil::ThumbCacheClear()
-{
- CThumbnailCache::GetThumbnailCache()->Clear();
-}
-
-bool CUtil::ThumbCached(const CStdString& strFileName)
-{
- return CThumbnailCache::GetThumbnailCache()->IsCached(strFileName);
-}
-
CStdString CUtil::GetNextFilename(const CStdString &fn_template, int max)
{
if (!fn_template.Find("%03d"))
View
4 xbmc/Util.h
@@ -87,10 +87,6 @@ class CUtil
static bool FindVobSubPair( const std::vector<CStdString>& vecSubtitles, const CStdString& strIdxPath, CStdString& strSubPath );
static bool IsVobSub( const std::vector<CStdString>& vecSubtitles, const CStdString& strSubPath );
static int64_t ToInt64(uint32_t high, uint32_t low);
- static bool ThumbExists(const CStdString& strFileName, bool bAddCache = false);
- static bool ThumbCached(const CStdString& strFileName);
- static void ThumbCacheAdd(const CStdString& strFileName, bool bFileExists);
- static void ThumbCacheClear();
static CStdString GetNextFilename(const CStdString &fn_template, int max);
static CStdString GetNextPathname(const CStdString &path_template, int max);
static void TakeScreenshot();
View
116 xbmc/filesystem/DirectoryCache.cpp
@@ -50,8 +50,6 @@ void CDirectoryCache::CDir::SetLastAccess(unsigned int &accessCounter)
CDirectoryCache::CDirectoryCache(void)
{
- m_iThumbCacheRefCount = 0;
- m_iMusicThumbCacheRefCount = 0;
m_accessCounter = 0;
#ifdef _DEBUG
m_cacheHits = 0;
@@ -202,17 +200,12 @@ bool CDirectoryCache::FileExists(const CStdString& strFile, bool& bInCache)
void CDirectoryCache::Clear()
{
- // this routine clears everything except things we always cache
+ // this routine clears everything
CSingleLock lock (m_cs);
iCache i = m_cache.begin();
while (i != m_cache.end() )
- {
- if (!IsCacheDir(i->first))
- Delete(i++);
- else
- i++;
- }
+ Delete(i++);
}
void CDirectoryCache::InitCache(set<CStdString>& dirs)
@@ -239,98 +232,6 @@ void CDirectoryCache::ClearCache(set<CStdString>& dirs)
}
}
-bool CDirectoryCache::IsCacheDir(const CStdString &strPath) const
-{
- if (m_thumbDirs.find(strPath) == m_thumbDirs.end())
- return false;
- if (m_musicThumbDirs.find(strPath) == m_musicThumbDirs.end())
- return false;
-
- return true;
-}
-
-void CDirectoryCache::InitThumbCache()
-{
- CSingleLock lock (m_cs);
-
- if (m_iThumbCacheRefCount > 0)
- {
- m_iThumbCacheRefCount++;
- return ;
- }
- m_iThumbCacheRefCount++;
-
- // Init video, pictures cache directories
- if (m_thumbDirs.size() == 0)
- {
- // thumbnails directories
-/* m_thumbDirs.insert(g_settings.GetThumbnailsFolder());
- for (unsigned int hex=0; hex < 16; hex++)
- {
- CStdString strHex;
- strHex.Format("\\%x",hex);
- m_thumbDirs.insert(g_settings.GetThumbnailsFolder() + strHex);
- }*/
- }
-
- InitCache(m_thumbDirs);
-}
-
-void CDirectoryCache::ClearThumbCache()
-{
- CSingleLock lock (m_cs);
-
- if (m_iThumbCacheRefCount > 1)
- {
- m_iThumbCacheRefCount--;
- return ;
- }
-
- m_iThumbCacheRefCount--;
- ClearCache(m_thumbDirs);
-}
-
-void CDirectoryCache::InitMusicThumbCache()
-{
- CSingleLock lock (m_cs);
-
- if (m_iMusicThumbCacheRefCount > 0)
- {
- m_iMusicThumbCacheRefCount++;
- return ;
- }
- m_iMusicThumbCacheRefCount++;
-
- // Init music cache directories
- if (m_musicThumbDirs.size() == 0)
- {
- // music thumbnails directories
- for (int i = 0; i < 16; i++)
- {
- CStdString hex, folder;
- hex.Format("%x", i);
- URIUtils::AddFileToFolder(g_settings.GetMusicThumbFolder(), hex, folder);
- m_musicThumbDirs.insert(folder);
- }
- }
-
- InitCache(m_musicThumbDirs);
-}
-
-void CDirectoryCache::ClearMusicThumbCache()
-{
- CSingleLock lock (m_cs);
-
- if (m_iMusicThumbCacheRefCount > 1)
- {
- m_iMusicThumbCacheRefCount--;
- return ;
- }
-
- m_iMusicThumbCacheRefCount--;
- ClearCache(m_musicThumbDirs);
-}
-
void CDirectoryCache::CheckIfFull()
{
CSingleLock lock (m_cs);
@@ -342,7 +243,7 @@ void CDirectoryCache::CheckIfFull()
for (iCache i = m_cache.begin(); i != m_cache.end(); i++)
{
// ensure dirs that are always cached aren't cleared
- if (!IsCacheDir(i->first) && i->second->m_cacheType != DIR_CACHE_ALWAYS)
+ if (i->second->m_cacheType != DIR_CACHE_ALWAYS)
{
if (lastAccessed == m_cache.end() || i->second->GetLastAccess() < lastAccessed->second->GetLastAccess())
lastAccessed = i;
@@ -371,13 +272,10 @@ void CDirectoryCache::PrintStats() const
unsigned int numDirs = 0;
for (ciCache i = m_cache.begin(); i != m_cache.end(); i++)
{
- if (!IsCacheDir(i->first))
- {
- CDir *dir = i->second;
- oldest = min(oldest, dir->GetLastAccess());
- numItems += dir->m_Items->Size();
- numDirs++;
- }
+ CDir *dir = i->second;
+ oldest = min(oldest, dir->GetLastAccess());
+ numItems += dir->m_Items->Size();
+ numDirs++;
}
CLog::Log(LOGDEBUG, "%s - %u folders cached, with %u items total. Oldest is %u, current is %u", __FUNCTION__, numDirs, numItems, oldest, m_accessCounter);
}
View
9 xbmc/filesystem/DirectoryCache.h
@@ -58,17 +58,12 @@ namespace XFILE
void Clear();
void AddFile(const CStdString& strFile);
bool FileExists(const CStdString& strPath, bool& bInCache);
- void InitThumbCache();
- void ClearThumbCache();
- void InitMusicThumbCache();
- void ClearMusicThumbCache();
#ifdef _DEBUG
void PrintStats() const;
#endif
protected:
void InitCache(std::set<CStdString>& dirs);
void ClearCache(std::set<CStdString>& dirs);
- bool IsCacheDir(const CStdString &strPath) const;
void CheckIfFull();
std::map<CStdString, CDir*> m_cache;
@@ -77,10 +72,6 @@ namespace XFILE
void Delete(iCache i);
CCriticalSection m_cs;
- std::set<CStdString> m_thumbDirs;
- std::set<CStdString> m_musicThumbDirs;
- int m_iThumbCacheRefCount;
- int m_iMusicThumbCacheRefCount;
unsigned int m_accessCounter;
View
6 xbmc/music/MusicInfoLoader.cpp
@@ -64,9 +64,6 @@ void CMusicInfoLoader::OnLoaderStart()
m_mapFileItems->SetFastLookup(true);
}
- // Precache album thumbs
- g_directoryCache.InitMusicThumbCache();
-
m_strPrevPath.Empty();
m_databaseHits = m_tagReads = 0;
@@ -186,9 +183,6 @@ bool CMusicInfoLoader::LoadItem(CFileItem* pItem)
void CMusicInfoLoader::OnLoaderFinish()
{
- // clear precached album thumbs
- g_directoryCache.ClearMusicThumbCache();
-
// cleanup last loaded songs from database
m_songsMap.Clear();
View
8 xbmc/music/infoscanner/MusicInfoScanner.cpp
@@ -24,7 +24,6 @@
#include "music/tags/MusicInfoTagLoaderFactory.h"
#include "MusicAlbumInfo.h"
#include "MusicInfoScraper.h"
-#include "filesystem/DirectoryCache.h"
#include "filesystem/MusicDatabaseDirectory.h"
#include "filesystem/MusicDatabaseDirectory/DirectoryNode.h"
#include "Util.h"
@@ -38,6 +37,7 @@
#include "dialogs/GUIDialogSelect.h"
#include "dialogs/GUIDialogKeyboard.h"
#include "filesystem/File.h"
+#include "filesystem/Directory.h"
#include "settings/AdvancedSettings.h"
#include "settings/GUISettings.h"
#include "settings/Settings.h"
@@ -85,9 +85,6 @@ void CMusicInfoScanner::Process()
m_bCanInterrupt = true;
- CUtil::ThumbCacheClear();
- g_directoryCache.ClearMusicThumbCache();
-
if (m_scanType == 0) // load info from files
{
CLog::Log(LOGDEBUG, "%s - Starting scan", __FUNCTION__);
@@ -149,9 +146,6 @@ void CMusicInfoScanner::Process()
m_musicDatabase.EmptyCache();
- CUtil::ThumbCacheClear();
- g_directoryCache.ClearMusicThumbCache();
-
m_musicDatabase.Close();
CLog::Log(LOGDEBUG, "%s - Finished scan", __FUNCTION__);
View
1 xbmc/music/windows/GUIWindowMusicBase.cpp
@@ -92,7 +92,6 @@ bool CGUIWindowMusicBase::OnBack(int actionID)
{
if (!g_application.IsMusicScanning())
{
- CUtil::ThumbCacheClear();
CUtil::RemoveTempFiles();
}
return CGUIMediaWindow::OnBack(actionID);
View
120 xbmc/pictures/Picture.cpp
@@ -34,113 +34,6 @@
using namespace XFILE;
-bool CPicture::CreateThumbnail(const CStdString& file, const CStdString& thumbFile, bool checkExistence /*= false*/)
-{
- // don't create the thumb if it already exists
- if (checkExistence && CFile::Exists(thumbFile))
- return true;
-
- return CacheImage(file, thumbFile, g_advancedSettings.m_thumbSize, g_advancedSettings.m_thumbSize);
-}
-
-bool CPicture::CacheImage(const CStdString& sourceUrl, const CStdString& destFile, int width, int height)
-{
- if (width > 0 && height > 0)
- {
- CLog::Log(LOGINFO, "Caching image from: %s to %s with width %i and height %i", sourceUrl.c_str(), destFile.c_str(), width, height);
-
- CJpegIO jpegImage;
- DllImageLib dll;
-
- if (URIUtils::IsInternetStream(sourceUrl, true))
- {
- CCurlFile http;
- CStdString data;
- if (http.Get(sourceUrl, data))
- {
- if (URIUtils::GetExtension(sourceUrl).Equals(".jpg") || URIUtils::GetExtension(sourceUrl).Equals(".tbn"))
- {
- if (jpegImage.CreateThumbnailFromMemory((unsigned char *)data.c_str(), data.GetLength(), destFile.c_str(), width, height))
- return true;
- }
- if (!dll.Load()) return false;
- if (!dll.CreateThumbnailFromMemory((BYTE *)data.c_str(), data.GetLength(), URIUtils::GetExtension(sourceUrl).c_str(), destFile.c_str(), width, height))
- {
- CLog::Log(LOGERROR, "%s Unable to create new image %s from image %s", __FUNCTION__, destFile.c_str(), sourceUrl.c_str());
- return false;
- }
- return true;
- }
- return false;
- }
-
- if (URIUtils::GetExtension(sourceUrl).Equals(".jpg") || URIUtils::GetExtension(sourceUrl).Equals(".tbn"))
- {
- if (jpegImage.CreateThumbnail(sourceUrl, destFile, width, height, g_guiSettings.GetBool("pictures.useexifrotation")))
- return true;
- }
- if (!dll.Load()) return false;
- if (!dll.CreateThumbnail(sourceUrl.c_str(), destFile.c_str(), width, height, g_guiSettings.GetBool("pictures.useexifrotation")))
- {
- CLog::Log(LOGERROR, "%s Unable to create new image %s from image %s", __FUNCTION__, destFile.c_str(), sourceUrl.c_str());
- return false;
- }
- return true;
- }
- else
- {
- CLog::Log(LOGINFO, "Caching image from: %s to %s", sourceUrl.c_str(), destFile.c_str());
- return CFile::Cache(sourceUrl, destFile);
- }
-}
-
-bool CPicture::CacheThumb(const CStdString& sourceUrl, const CStdString& destFile)
-{
- return CacheImage(sourceUrl, destFile, g_advancedSettings.m_thumbSize, g_advancedSettings.m_thumbSize);
-}
-
-bool CPicture::CacheFanart(const CStdString& sourceUrl, const CStdString& destFile)
-{
- int height = g_advancedSettings.m_fanartHeight;
- // Assume 16:9 size
- int width = height * 16 / 9;
-
- return CacheImage(sourceUrl, destFile, width, height);
-}
-
-bool CPicture::CreateThumbnailFromMemory(const unsigned char* buffer, int bufSize, const CStdString& extension, const CStdString& thumbFile)
-{
- CLog::Log(LOGINFO, "Creating album thumb from memory: %s", thumbFile.c_str());
- if (extension.Equals("jpg") || extension.Equals("tbn"))
- {
- CJpegIO jpegImage;
- if (jpegImage.CreateThumbnailFromMemory((unsigned char*)buffer, bufSize, thumbFile.c_str(), g_advancedSettings.m_thumbSize, g_advancedSettings.m_thumbSize))
- return true;
- }
- DllImageLib dll;
- if (!dll.Load()) return false;
- if (!dll.CreateThumbnailFromMemory((BYTE *)buffer, bufSize, extension.c_str(), thumbFile.c_str(), g_advancedSettings.m_thumbSize, g_advancedSettings.m_thumbSize))
- {
- CLog::Log(LOGERROR, "%s: exception with fileType: %s", __FUNCTION__, extension.c_str());
- return false;
- }
- return true;
-}
-
-void CPicture::CreateFolderThumb(const CStdString *thumbs, const CStdString &folderThumb)
-{ // we want to mold the thumbs together into one single one
- const char *szThumbs[4];
- for (int i=0; i < 4; i++)
- szThumbs[i] = thumbs[i].c_str();
-
- DllImageLib dll;
- if (!dll.Load()) return;
- if (!dll.CreateFolderThumbnail(szThumbs, folderThumb.c_str(), g_advancedSettings.m_thumbSize, g_advancedSettings.m_thumbSize))
- {
- CLog::Log(LOGERROR, "%s failed for folder thumb %s", __FUNCTION__, folderThumb.c_str());
- }
-}
-
bool CPicture::CreateThumbnailFromSurface(const unsigned char *buffer, int width, int height, int stride, const CStdString &thumbFile)
{
if (URIUtils::GetExtension(thumbFile).Equals(".jpg"))
@@ -154,19 +47,6 @@ bool CPicture::CreateThumbnailFromSurface(const unsigned char *buffer, int width
return dll.CreateThumbnailFromSurface((BYTE *)buffer, width, height, stride, thumbFile.c_str());
}
-int CPicture::ConvertFile(const CStdString &srcFile, const CStdString &destFile, float rotateDegrees, int width, int height, unsigned int quality, bool mirror)
-{
- DllImageLib dll;
- if (!dll.Load()) return false;
- int ret = dll.ConvertFile(srcFile.c_str(), destFile.c_str(), rotateDegrees, width, height, quality, mirror);
- if (ret)
- {
- CLog::Log(LOGERROR, "%s: Error %i converting image %s", __FUNCTION__, ret, srcFile.c_str());
- return ret;
- }
- return ret;
-}
-
CThumbnailWriter::CThumbnailWriter(unsigned char* buffer, int width, int height, int stride, const CStdString& thumbFile)
{
m_buffer = buffer;
View
8 xbmc/pictures/Picture.h
@@ -27,14 +27,7 @@ class CBaseTexture;
class CPicture
{
public:
- static bool CreateThumbnailFromMemory(const unsigned char* buffer, int bufSize, const CStdString& extension, const CStdString& thumbFile);
static bool CreateThumbnailFromSurface(const unsigned char* buffer, int width, int height, int stride, const CStdString &thumbFile);
- static int ConvertFile(const CStdString& srcFile, const CStdString& destFile, float rotateDegrees, int width, int height, unsigned int quality, bool mirror=false);
-
- static void CreateFolderThumb(const CStdString *thumbs, const CStdString &folderThumb);
- static bool CreateThumbnail(const CStdString& file, const CStdString& thumbFile, bool checkExistence = false);
- static bool CacheThumb(const CStdString& sourceUrl, const CStdString& destFile);
- static bool CacheFanart(const CStdString& SourceUrl, const CStdString& destFile);
/*! \brief Create a tiled thumb of the given files
\param files the files to create the thumb from
@@ -53,7 +46,6 @@ class CPicture
static bool CacheTexture(uint8_t *pixels, uint32_t width, uint32_t height, uint32_t pitch, int orientation, uint32_t &dest_width, uint32_t &dest_height, const std::string &dest);
private:
- static bool CacheImage(const CStdString& sourceUrl, const CStdString& destFile, int width, int height);
static void GetScale(unsigned int width, unsigned int height, unsigned int &out_width, unsigned int &out_height);
static bool ScaleImage(uint8_t *in_pixels, unsigned int in_width, unsigned int in_height, unsigned int in_pitch,
uint8_t *out_pixels, unsigned int out_width, unsigned int out_height, unsigned int out_pitch);
View
41 xbmc/utils/Fanart.cpp
@@ -22,10 +22,7 @@
#include "Fanart.h"
#include "utils/XBMCTinyXML.h"
#include "URIUtils.h"
-#include "pictures/Picture.h"
-#include "filesystem/CurlFile.h"
#include "StringUtils.h"
-#include "filesystem/File.h"
const unsigned int CFanart::max_fanart_colors=3;
@@ -133,44 +130,6 @@ bool CFanart::SetPrimaryFanart(unsigned int index)
return true;
}
-bool CFanart::DownloadThumb(unsigned int index, const CStdString &strDestination) const
-{
- if (index >= m_fanart.size())
- return false;
-
- CStdString thumbURL;
- if (!m_fanart[index].strPreview.IsEmpty())
- {
- if (m_url.IsEmpty())
- thumbURL = m_fanart[index].strPreview;
- else
- thumbURL = URIUtils::AddFileToFolder(m_url, m_fanart[index].strPreview);
-
- XFILE::CCurlFile http;
- if (http.Download(thumbURL, strDestination))
- return true;
- }
-
- // try downloading the image instead
- if (m_url.IsEmpty())
- thumbURL = m_fanart[index].strImage;
- else
- thumbURL = URIUtils::AddFileToFolder(m_url, m_fanart[index].strImage);
- return DownloadImage(thumbURL, strDestination);
-}
-
-bool CFanart::DownloadImage(const CStdString &url, const CStdString &destination) const
-{
- return CPicture::CacheFanart(url, destination);
-}
-
-bool CFanart::DownloadImage(const CStdString &strDestination) const
-{
- if (m_fanart.size() == 0)
- return false;
- return DownloadImage(GetImageURL(), strDestination);
-}
-
unsigned int CFanart::GetNumFanarts()
{
return m_fanart.size();
View
20 xbmc/utils/Fanart.h
@@ -80,19 +80,6 @@ class CFanart
/// \return A boolean value indicating success or failure. This should only return false if the specified index is not a valid fanart
bool SetPrimaryFanart(unsigned int index);
///
- /// Downloads the indicated fanart thumbnail into the specified file
- /// \param index: 0 based index specfying which fanart thumb should be downloaded
- /// \param strDestination: CStdString full path and filename indicating where to store the thumbnail
- /// \return A boolean indicating success or failure of the download
- bool DownloadThumb(unsigned int index, const CStdString &strDestination) const;
- ///
- /// Downloads the primary fanart full resolution image
- ///
- /// This interface ONLY downloads the primary image because there should not be a reason to download any other
- /// \param strDestination: CStdString full path and filename indicating where to store the image
- /// \return A boolean indicating success of failure of the download
- bool DownloadImage(const CStdString &strDestination) const;
- ///
/// Returns how many fanarts are stored
/// \return An integer indicating how many fanarts are stored in the class. Fanart indices are 0 to (GetNumFanarts() - 1)
unsigned int GetNumFanarts();
@@ -104,13 +91,6 @@ class CFanart
/// also the interface used to pass the fanart data from the scraper to CFanart.
CStdString m_xml;
private:
- ///
- /// Downloads the specified image to the specified destination
- ///
- /// \param url: CStdString full url indicating where to download the image from
- /// \param destination: CStdString full path and filename indicating where to store the image
- /// \return A boolean indicating success of failure of the download
- bool DownloadImage(const CStdString &url, const CStdString &destination) const;
static const unsigned int max_fanart_colors;
///
/// Parse various color formats as returned by the sites scraped into a format we recognize
View
37 xbmc/utils/ScraperUrl.cpp
@@ -27,7 +27,6 @@
#include "URL.h"
#include "filesystem/CurlFile.h"
#include "filesystem/ZipFile.h"
-#include "pictures/Picture.h"
#include "URIUtils.h"
#include <cstring>
@@ -255,42 +254,6 @@ bool CScraperUrl::Get(const SUrlEntry& scrURL, std::string& strHTML, XFILE::CCur
return true;
}
-bool CScraperUrl::DownloadThumbnail(const CStdString &thumb, const CScraperUrl::SUrlEntry& entry)
-{
- if (entry.m_url.IsEmpty())
- return false;
-
- CURL url(entry.m_url);
- if (url.GetProtocol() != "http")
- { // do a direct file copy
- try
- {
- return CPicture::CreateThumbnail(entry.m_url, thumb);
- }
- catch (...)
- {
- XFILE::CFile::Delete(thumb);
- }
- return false;
- }
-
- XFILE::CCurlFile http;
- http.SetReferer(entry.m_spoof);
- CStdString thumbData;
- if (http.Get(entry.m_url, thumbData))
- {
- try
- {
- return CPicture::CreateThumbnailFromMemory((const BYTE *)thumbData.c_str(), thumbData.size(), URIUtils::GetExtension(entry.m_url), thumb);
- }
- catch (...)
- {
- XFILE::CFile::Delete(thumb);
- }
- }
- return false;
-}
-
// XML format is of strUrls is:
// <TAG><url>...</url>...</TAG> (parsed by ParseElement) or <url>...</url> (ditto)
bool CScraperUrl::ParseEpisodeGuide(CStdString strUrls)
View
1 xbmc/utils/ScraperUrl.h
@@ -77,7 +77,6 @@ class CScraperUrl
void Clear();
static bool Get(const SUrlEntry&, std::string&, XFILE::CCurlFile& http,
const CStdString& cacheContext);
- static bool DownloadThumbnail(const CStdString &thumb, const SUrlEntry& entry);
CStdString m_xml;
CStdString m_spoof; // for backwards compatibility only!
View
20 xbmc/video/VideoInfoScanner.cpp
@@ -28,7 +28,6 @@
#include "NfoFile.h"
#include "utils/RegExp.h"
#include "utils/md5.h"
-#include "pictures/Picture.h"
#include "filesystem/StackDirectory.h"
#include "VideoInfoDownloader.h"
#include "GUIInfoManager.h"
@@ -1191,25 +1190,6 @@ namespace VIDEO
ApplyThumbToFolder(parentDir, thumb);
}
- void CVideoInfoScanner::DownloadImage(const CStdString &url, const CStdString &destination, bool asThumb /*= true */, CGUIDialogProgress *progress /*= NULL */)
- {
- if (progress)
- {
- progress->SetLine(2, 415);
- progress->Progress();
- }
- bool result = false;
- if (asThumb)
- result = CPicture::CreateThumbnail(url, destination);
- else
- result = CPicture::CacheFanart(url, destination);
- if (!result)
- {
- CFile::Delete(destination);
- return;
- }
- }
-
INFO_RET CVideoInfoScanner::OnProcessSeriesFolder(EPISODES& files, const ADDON::ScraperPtr &scraper, bool useLocal, int idShow, const CStdString& strShowTitle, CGUIDialogProgress* pDlgProgress /* = NULL */)
{
if (pDlgProgress)
View
9 xbmc/video/VideoInfoScanner.h
@@ -214,15 +214,6 @@ namespace VIDEO
*/
bool CanFastHash(const CFileItemList &items) const;
- /*! \brief Download an image file and apply the image to a folder if necessary
- \param url URL of the image.
- \param destination File to save the image as
- \param asThumb whether we need to download as a thumbnail or as a full image. Defaults to true
- \param progress progressbar to update - defaults to NULL
- \param directory directory that this thumbnail should be applied to. Defaults to empty
- */
- void DownloadImage(const CStdString &url, const CStdString &destination, bool asThumb = true, CGUIDialogProgress *dialog = NULL);
-
/*! \brief Process a series folder, filling in episode details and adding them to the database.
TODO: Ideally we would return INFO_HAVE_ALREADY if we don't have to update any episodes
and we should return INFO_NOT_FOUND only if no information is found for any of
View
4 xbmc/video/dialogs/GUIDialogVideoInfo.cpp
@@ -650,10 +650,6 @@ void CGUIDialogVideoInfo::OnGetThumb()
return; // user chose the one they have
CStdString newThumb;
- // delete the thumbnail if that's what the user wants, else overwrite with the
- // new thumbnail
- CFileItem item(*m_movieItem->GetVideoInfoTag());
-
if (result.Left(14) == "thumb://Remote")
{
int number = atoi(result.Mid(14));

0 comments on commit 3ae8891

Please sign in to comment.