Add audio_cache_size to set maximum cache size

This commit is contained in:
Henrik Friedrichsen
2021-05-07 23:13:03 +02:00
parent f0d5e31c86
commit 5fd93c33cb
3 changed files with 5 additions and 1 deletions

View File

@@ -185,6 +185,7 @@ Possible configuration values are:
* `backend_device`: Audio device string to configure the backend
* `audio_cache`: Enable or disable caching of audio files, on by default
<true/false>
* `audio_cache_size`: Maximum size of audio cache in MiB
* `volnorm`: Enable or disable volume normalization, off by default <true/false>
* `volnorm_pregain`: Normalization pregain to apply (if enabled)
* `default_keybindings`: If disabled, the default keybindings are discarded, off

View File

@@ -21,6 +21,7 @@ pub struct ConfigValues {
pub theme: Option<ConfigTheme>,
pub use_nerdfont: Option<bool>,
pub audio_cache: Option<bool>,
pub audio_cache_size: Option<u32>,
pub backend: Option<String>,
pub backend_device: Option<String>,
pub volnorm: Option<bool>,

View File

@@ -162,7 +162,9 @@ impl Spotify {
let cache = Cache::new(
Some(config::cache_path("librespot")),
audio_cache_path,
None,
cfg.values()
.audio_cache_size
.map(|size| (size * 1048576) as u64),
)
.expect("Could not create cache");
debug!("opening spotify session");