vapoursynth: Add a preferred cache directory and clean it when necessary
This commit is contained in:
parent
32aaf6372c
commit
c348f8582a
6 changed files with 26 additions and 0 deletions
|
@ -56,6 +56,8 @@ public:
|
|||
VapoursynthAudioProvider::VapoursynthAudioProvider(agi::fs::path const& filename) try {
|
||||
std::lock_guard<std::mutex> lock(vs.GetMutex());
|
||||
|
||||
VSCleanCache();
|
||||
|
||||
script = vs.GetScriptAPI()->createScript(nullptr);
|
||||
if (script == nullptr) {
|
||||
throw VapoursynthError("Error creating script API");
|
||||
|
|
|
@ -353,6 +353,12 @@
|
|||
"Index All Tracks" : true,
|
||||
"Log Level" : "quiet"
|
||||
},
|
||||
"VapourSynth" : {
|
||||
"Cache" : {
|
||||
"Files" : 500,
|
||||
"Size" : 1000
|
||||
}
|
||||
},
|
||||
"Video" : {
|
||||
"Cache" : {
|
||||
"Size" : 32
|
||||
|
|
|
@ -353,6 +353,12 @@
|
|||
"Index All Tracks" : true,
|
||||
"Log Level" : "quiet"
|
||||
},
|
||||
"VapourSynth" : {
|
||||
"Cache" : {
|
||||
"Files" : 500,
|
||||
"Size" : 1000
|
||||
}
|
||||
},
|
||||
"Video" : {
|
||||
"Cache" : {
|
||||
"Size" : 32
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
#include "vapoursynth_wrap.h"
|
||||
#include "options.h"
|
||||
#include "utils.h"
|
||||
#include <libaegisub/fs.h>
|
||||
#include <libaegisub/path.h>
|
||||
|
||||
|
@ -39,6 +40,7 @@ int OpenScriptOrVideo(const VSAPI *api, const VSSCRIPTAPI *sapi, VSScript *scrip
|
|||
throw VapoursynthError("Failed to create VSMap for script info");
|
||||
|
||||
SetStringVar(api, map, "filename", filename.string());
|
||||
SetStringVar(api, map, "__aegi_vscache", config::path->Decode("?local/vscache").string());
|
||||
for (std::string dir : { "data", "dictionary", "local", "script", "temp", "user", })
|
||||
// Don't include ?audio and ?video in here since these only hold the paths to the previous audio/video files.
|
||||
SetStringVar(api, map, "__aegi_" + dir, config::path->Decode("?" + dir).string());
|
||||
|
@ -58,4 +60,11 @@ int OpenScriptOrVideo(const VSAPI *api, const VSSCRIPTAPI *sapi, VSScript *scrip
|
|||
return result;
|
||||
}
|
||||
|
||||
void VSCleanCache() {
|
||||
CleanCache(config::path->Decode("?local/vscache/"),
|
||||
"",
|
||||
OPT_GET("Provider/VapourSynth/Cache/Size")->GetInt(),
|
||||
OPT_GET("Provider/VapourSynth/Cache/Files")->GetInt());
|
||||
}
|
||||
|
||||
#endif // WITH_VAPOURSYNTH
|
||||
|
|
|
@ -20,5 +20,6 @@
|
|||
#include <libaegisub/fs_fwd.h>
|
||||
|
||||
int OpenScriptOrVideo(const VSAPI *api, const VSSCRIPTAPI *sapi, VSScript *script, agi::fs::path const& filename, std::string default_script);
|
||||
void VSCleanCache();
|
||||
|
||||
#endif // WITH_VAPOURSYNTH
|
||||
|
|
|
@ -111,6 +111,8 @@ void VapoursynthVideoProvider::SetResizeArg(VSMap *args, const VSMap *props, con
|
|||
VapoursynthVideoProvider::VapoursynthVideoProvider(agi::fs::path const& filename, std::string const& colormatrix) try {
|
||||
std::lock_guard<std::mutex> lock(vs.GetMutex());
|
||||
|
||||
VSCleanCache();
|
||||
|
||||
script = vs.GetScriptAPI()->createScript(nullptr);
|
||||
if (script == nullptr) {
|
||||
throw VapoursynthError("Error creating script API");
|
||||
|
|
Loading…
Reference in a new issue