Remove cache cleaning code from ffms, I'll eventually write something in libaegisub as we need cache cleaning for other areas too. (debug log, crash logs etc)

Originally committed to SVN as r5330.
This commit is contained in:
Amar Takhar 2011-02-09 21:53:37 +00:00
parent ce912335f1
commit a118487afa
3 changed files with 0 additions and 145 deletions

View File

@ -263,128 +263,6 @@ std::string toHash = "XXX";
return "XXX";
}
/// @brief Starts the cache cleaner thread
/// @return True on success, false if the thread could not be started.
bool FFmpegSourceProvider::CleanCache() {
/*
LOG_D("provider/ffmpegsource/cache") << "attempting to start thread";
FFmpegSourceCacheCleaner *CleaningThread = new FFmpegSourceCacheCleaner(this);
if (CleaningThread->Create() != wxTHREAD_NO_ERROR) {
LOG_D("provider/ffmpegsource/cache") << "thread creation failed";
delete CleaningThread;
CleaningThread = NULL;
return false;
}
if (CleaningThread->Run() != wxTHREAD_NO_ERROR) {
LOG_D("provider/ffmpegsource/cache") << "failed to start thread";
delete CleaningThread;
CleaningThread = NULL;
return false;
}
LOG_D("provider/ffmpegsource/cache") << "thread started successfully";
return true;
*/
}
/*
/// @brief constructor
/// @param par the parent provider
FFmpegSourceCacheCleaner::FFmpegSourceCacheCleaner(FFmpegSourceProvider *par) : wxThread(wxTHREAD_DETACHED) {
parent = par;
}
/// @brief Cleans the ffms2 index cache folder
/// @return Returns non-0 on error, 0 otherwise.
wxThread::ExitCode FFmpegSourceCacheCleaner::Entry() {
wxMutexLocker lock(FFmpegSourceProvider::CleaningInProgress);
if (!lock.IsOk()) {
LOG_D("provider/ffmpegsource/cache") << "cleaning already in progress, thread exiting";
return (wxThread::ExitCode)1;
}
wxString cachedirname = StandardPaths::DecodePath(_T("?user/ffms2cache/"));
wxDir cachedir;
if (!cachedir.Open(cachedirname)) {
LOG_D("provider/ffmpegsource/cache") << "couldn't open cache directory " << cachedirname.c_str();
return (wxThread::ExitCode)1;
}
// sleep for a bit so we (hopefully) don't thrash the disk too much while indexing is in progress
wxThread::This()->Sleep(2000);
// the option is in megabytes, we need bytes
// shift left by 20 is CLEARLY more efficient than multiplying by 1048576
int64_t maxsize = OPT_GET("Provider/FFmpegSource/Cache/Size")->GetInt() << 20;
int64_t cursize = wxDir::GetTotalSize(cachedirname).GetValue();
int maxfiles = OPT_GET("Provider/FFmpegSource/Cache/Files")->GetInt();
if (!cachedir.HasFiles(_T("*.ffindex"))) {
LOG_D("provider/ffmpegsource/cache") << "no index files in cache folder, exiting";
return (wxThread::ExitCode)0;
}
int deleted = 0;
int numfiles = 0;
std::multimap<int64_t,wxFileName> cachefiles;
wxString curfn_str;
wxFileName curfn;
wxDateTime curatime;
// unusually paranoid sanity check
// (someone might have deleted the file(s) after we did HasFiles() above; does wxDir.Open() lock the dir?)
if (!cachedir.GetFirst(&curfn_str, _T("*.ffindex"), wxDIR_FILES)) {
LOG_D("provider/ffmpegsource/cache") << "undefined error";
return (wxThread::ExitCode)1;
}
numfiles++;
curfn = wxFileName(cachedirname, curfn_str);
curfn.GetTimes(&curatime, NULL, NULL);
// FIXME: will break when the time_t's wrap around!!1!
cachefiles.insert(std::pair<int64_t,wxFileName>(curatime.GetTicks(),curfn));
while (cachedir.GetNext(&curfn_str)) {
curfn = wxFileName(cachedirname, curfn_str);
curfn.GetTimes(&curatime, NULL, NULL);
cachefiles.insert(std::pair<int64_t,wxFileName>(curatime.GetTicks(),curfn));
numfiles++;
wxThread::This()->Sleep(250);
}
if (numfiles <= maxfiles && cursize <= maxsize) {
LOG_D("provider/ffmpegsource/cache") << "cache does not need cleaning (maxsize=" << (int)maxsize << ", cursize=" << (int)cursize << "; maxfiles=" << maxfiles << "numfiles=" << numfiles << ",exiting";
return (wxThread::ExitCode)0;
}
for (std::multimap<int64_t,wxFileName>::iterator i = cachefiles.begin(); i != cachefiles.end(); i++) {
// stop cleaning?
if ((cursize <= maxsize && numfiles <= maxfiles) || numfiles <= 1)
break;
int64_t fsize = i->second.GetSize().GetValue();
if (!wxRemoveFile(i->second.GetFullPath())) {
LOG_D("provider/ffmpegsource/cache") << "failed to remove file " << i->second.GetFullPath().c_str();
continue;
}
cursize -= fsize;
numfiles--;
deleted++;
wxThread::This()->Sleep(250);
}
LOG_D("provider/ffmpegsource/cache") << "deleted " << deleted << " files, exiting";
return (wxThread::ExitCode)0;
}
*/
#endif // WITH_FFMPEGSOURCE

View File

@ -58,7 +58,6 @@ namespace media {
/// @class FFmpegSourceProvider
/// @brief Base class for FFMS2 source providers; contains common functions etc
class FFmpegSourceProvider {
friend class FFmpegSourceCacheCleaner;
public:
/// Logging level constants from avutil/log.h
enum FFMS_LogLevel {
@ -79,10 +78,6 @@ public:
// DialogProgress *ProgressDialog;
};
/// Mutex preventing two cache cleaner threads from running at the same time
// static wxMutex CleaningInProgress;
bool CleanCache();
static int FFMS_CC UpdateIndexingProgress(int64_t Current, int64_t Total, void *Private);
FFMS_Index *DoIndexing(FFMS_Indexer *Indexer, const std::string& Cachename, int Trackmask, FFMS_IndexErrorHandling IndexEH);
@ -95,19 +90,6 @@ public:
virtual ~FFmpegSourceProvider() {}
};
/// @class FFmpegSourceCacheCleaner
/// @brief Implements index cache cleaning functionality for the FFMS2 providers
class FFmpegSourceCacheCleaner {
private:
FFmpegSourceProvider *parent;
public:
FFmpegSourceCacheCleaner(FFmpegSourceProvider *par);
~FFmpegSourceCacheCleaner() {};
// wxThread::ExitCode Entry();
};
#endif /* WITH_FFMPEGSOURCE */
} // namespace ffms

View File

@ -167,11 +167,6 @@ void FFmpegSourceVideoProvider::LoadVideo(std::string filename) {
// update access time of index file so it won't get cleaned away
//XXX: wxFileName(CacheName).Touch();
// we have now read the index and may proceed with cleaning the index cache
if (!CleanCache()) {
//do something?
}
// track number still not set?
if (TrackNumber < 0) {
// just grab the first track