1
0
Fork 0

bestsource: Clean index cache when necessary

This commit is contained in:
arch1t3cht 2023-01-31 02:47:02 +01:00
parent e2fb3a7e43
commit 15f4da61d3
6 changed files with 24 additions and 1 deletions

View File

@ -63,6 +63,7 @@ BSAudioProvider::BSAudioProvider(agi::fs::path const& filename, agi::BackgroundR
LOG_D("bs") << "File cached and has exact samples."; LOG_D("bs") << "File cached and has exact samples.";
} }
}); });
BSCleanCache();
properties = bs.GetAudioProperties(); properties = bs.GetAudioProperties();
float_samples = properties.IsFloat; float_samples = properties.IsFloat;
bytes_per_sample = properties.BytesPerSample; bytes_per_sample = properties.BytesPerSample;

View File

@ -23,6 +23,7 @@
#include "bestsource_common.h" #include "bestsource_common.h"
#include "options.h" #include "options.h"
#include "utils.h"
#include <libaegisub/fs.h> #include <libaegisub/fs.h>
#include <libaegisub/path.h> #include <libaegisub/path.h>
@ -45,5 +46,11 @@ std::string GetBSCacheFile(agi::fs::path const& filename) {
return result.string(); return result.string();
} }
void BSCleanCache() {
CleanCache(config::path->Decode("?local/bsindex/"),
"*.json",
OPT_GET("Provider/BestSource/Cache/Size")->GetInt(),
OPT_GET("Provider/BestSource/Cache/Files")->GetInt());
}
#endif // WITH_BESTSOURCE #endif // WITH_BESTSOURCE

View File

@ -1,4 +1,4 @@
// Copyright (c) 2022, arch1t3cht <arch1t3cht@gmail.com>> // Copyright (c) 2022, arch1t3cht <arch1t3cht@gmail.com>
// //
// Permission to use, copy, modify, and distribute this software for any // Permission to use, copy, modify, and distribute this software for any
// purpose with or without fee is hereby granted, provided that the above // purpose with or without fee is hereby granted, provided that the above
@ -24,5 +24,6 @@
#include <libaegisub/fs_fwd.h> #include <libaegisub/fs_fwd.h>
std::string GetBSCacheFile(agi::fs::path const& filename); std::string GetBSCacheFile(agi::fs::path const& filename);
void BSCleanCache();
#endif /* WITH_BESTSOURCE */ #endif /* WITH_BESTSOURCE */

View File

@ -350,6 +350,12 @@
"Index All Tracks" : true, "Index All Tracks" : true,
"Log Level" : "quiet" "Log Level" : "quiet"
}, },
"BestSource" : {
"Cache" : {
"Files" : 100,
"Size" : 42
}
},
"Video" : { "Video" : {
"Cache" : { "Cache" : {
"Size" : 32 "Size" : 32

View File

@ -350,6 +350,12 @@
"Index All Tracks" : true, "Index All Tracks" : true,
"Log Level" : "quiet" "Log Level" : "quiet"
}, },
"BestSource" : {
"Cache" : {
"Files" : 100,
"Size" : 42
}
},
"Video" : { "Video" : {
"Cache" : { "Cache" : {
"Size" : 32 "Size" : 32

View File

@ -158,6 +158,8 @@ BSVideoProvider::BSVideoProvider(agi::fs::path const& filename, std::string cons
} }
}); });
BSCleanCache();
// Decode the first frame to get the color space // Decode the first frame to get the color space
std::unique_ptr<BestVideoFrame> frame(bs.GetFrame(0)); std::unique_ptr<BestVideoFrame> frame(bs.GetFrame(0));
colorspace = colormatrix_description(frame->GetAVFrame()); colorspace = colormatrix_description(frame->GetAVFrame());