1
0
Fork 0
mirror of https://github.com/librespot-org/librespot.git synced 2025-10-03 01:39:28 +02:00

Cache volume across restarts (#220)

* create Volume struct for use with Cache

* add "volume" file to Cache

* load cached volume on start, intial overrides cached overrides default

* amend volume_to_mixer function to cache the volume on every change

* pass cache to Spirc and SpircTask so volume_to_mixer has access

* rustfmt changes

* revert volume_to_mixer function and Spirc/SpircTask cache variable

* Volume implements Copy, pass by value instead of reference

* clamp volume to 100 if cached value exceeds limit

* convert Volume to u16 internally, use float and round to convert hex->dec

* convert initial_volume and ConnectConfig.volume to u16 as well

* add cache_volume function to SpircTask

* remove conversion to/from percentage on cached volume

* consolidate device.set_volume, mixer.set_volume, and caching

* streamline intial volume logic
This commit is contained in:
Brice 2018-05-16 21:15:17 -04:00 committed by Paul Liétar
parent 21f1ccfb5a
commit d40c0f50db
8 changed files with 84 additions and 26 deletions

View file

@ -36,7 +36,7 @@ fn main() {
let session = core.run(Session::connect(session_config, credentials, None, handle))
.unwrap();
let (player, _)= Player::new(player_config, session.clone(), None, move || (backend)(None));
let (player, _) = Player::new(player_config, session.clone(), None, move || (backend)(None));
println!("Playing...");
core.run(player.load(track, true, 0)).unwrap();