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.";
}
});
BSCleanCache();
properties = bs.GetAudioProperties();
float_samples = properties.IsFloat;
bytes_per_sample = properties.BytesPerSample;

View file

@ -23,6 +23,7 @@
#include "bestsource_common.h"
#include "options.h"
#include "utils.h"
#include <libaegisub/fs.h>
#include <libaegisub/path.h>
@ -45,5 +46,11 @@ std::string GetBSCacheFile(agi::fs::path const& filename) {
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

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
// purpose with or without fee is hereby granted, provided that the above
@ -24,5 +24,6 @@
#include <libaegisub/fs_fwd.h>
std::string GetBSCacheFile(agi::fs::path const& filename);
void BSCleanCache();
#endif /* WITH_BESTSOURCE */

View file

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

View file

@ -350,6 +350,12 @@
"Index All Tracks" : true,
"Log Level" : "quiet"
},
"BestSource" : {
"Cache" : {
"Files" : 100,
"Size" : 42
}
},
"Video" : {
"Cache" : {
"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
std::unique_ptr<BestVideoFrame> frame(bs.GetFrame(0));
colorspace = colormatrix_description(frame->GetAVFrame());