[PR #220] [MERGED] Cache volume across restarts #841

Closed
opened 2026-02-27 20:00:10 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/librespot-org/librespot/pull/220
Author: @bricedp
Created: 5/11/2018
Status: Merged
Merged: 5/17/2018
Merged by: @plietar

Base: masterHead: cache-volume


📝 Commits (10+)

  • 47d1e54 create Volume struct for use with Cache
  • 141916a add "volume" file to Cache
  • d7708ee load cached volume on start, intial overrides cached overrides default
  • ab73804 amend volume_to_mixer function to cache the volume on every change
  • 814e371 pass cache to Spirc and SpircTask so volume_to_mixer has access
  • e71c7d3 rustfmt changes
  • 3975745 revert volume_to_mixer function and Spirc/SpircTask cache variable
  • e901456 Volume implements Copy, pass by value instead of reference
  • aca3428 clamp volume to 100 if cached value exceeds limit
  • 8f36283 convert Volume to u16 internally, use float and round to convert hex->dec

📊 Changes

8 files changed (+84 additions, -26 deletions)

View changed files

📝 connect/src/spirc.rs (+18 -14)
📝 core/src/cache.rs (+18 -0)
📝 core/src/config.rs (+1 -1)
📝 core/src/lib.rs (+1 -0)
core/src/volume.rs (+31 -0)
📝 examples/play.rs (+1 -1)
📝 playback/src/audio_backend/jackaudio.rs (+4 -2)
📝 src/main.rs (+10 -8)

📄 Description

This is a continuation of https://github.com/librespot-org/librespot/pull/218. Now, volume is cached when the user supplies the --cache directory. --initial-volume overrides cached volume, which in turn overrides the default hard-coded volume.

Currently, the volume is stored in a plaintext file containing only the (percentage) volume. In the future, it could be expanded into a config.json with other parameters as well, since I've largely copied the way that the credentials are stored in credentials.json.

I don't know if the final commit (passing to Spirc and SpircTask) is the most elegant way to access the cache from volume_to_mixer, so I'm open to any improvements to that aspect.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/librespot-org/librespot/pull/220 **Author:** [@bricedp](https://github.com/bricedp) **Created:** 5/11/2018 **Status:** ✅ Merged **Merged:** 5/17/2018 **Merged by:** [@plietar](https://github.com/plietar) **Base:** `master` ← **Head:** `cache-volume` --- ### 📝 Commits (10+) - [`47d1e54`](https://github.com/librespot-org/librespot/commit/47d1e54debd48dd9e9645538c4d8521c935958fc) create Volume struct for use with Cache - [`141916a`](https://github.com/librespot-org/librespot/commit/141916ab4b6915313ed2abe873b13176cb02ddb2) add "volume" file to Cache - [`d7708ee`](https://github.com/librespot-org/librespot/commit/d7708eebc6293cc11f2dc67c69e35609a092e567) load cached volume on start, intial overrides cached overrides default - [`ab73804`](https://github.com/librespot-org/librespot/commit/ab73804bd6258ca54c3a73de2a6cbc1898e7a58f) amend volume_to_mixer function to cache the volume on every change - [`814e371`](https://github.com/librespot-org/librespot/commit/814e371a686e112532b0b737c5d48608dbd220e2) pass cache to Spirc and SpircTask so volume_to_mixer has access - [`e71c7d3`](https://github.com/librespot-org/librespot/commit/e71c7d378ed3f7aa9177fd6377a4323fa90ea401) rustfmt changes - [`3975745`](https://github.com/librespot-org/librespot/commit/39757454e3e7fc9769cb774482255d031581f37d) revert volume_to_mixer function and Spirc/SpircTask cache variable - [`e901456`](https://github.com/librespot-org/librespot/commit/e901456da60c960ae6a2af34caa37edb8d38824f) Volume implements Copy, pass by value instead of reference - [`aca3428`](https://github.com/librespot-org/librespot/commit/aca3428f7a712046372e61f93e9201ab4023d4dd) clamp volume to 100 if cached value exceeds limit - [`8f36283`](https://github.com/librespot-org/librespot/commit/8f362830a1745c02bd784d3419e03c897f8b7de8) convert Volume to u16 internally, use float and round to convert hex->dec ### 📊 Changes **8 files changed** (+84 additions, -26 deletions) <details> <summary>View changed files</summary> 📝 `connect/src/spirc.rs` (+18 -14) 📝 `core/src/cache.rs` (+18 -0) 📝 `core/src/config.rs` (+1 -1) 📝 `core/src/lib.rs` (+1 -0) ➕ `core/src/volume.rs` (+31 -0) 📝 `examples/play.rs` (+1 -1) 📝 `playback/src/audio_backend/jackaudio.rs` (+4 -2) 📝 `src/main.rs` (+10 -8) </details> ### 📄 Description This is a continuation of [https://github.com/librespot-org/librespot/pull/218](https://github.com/librespot-org/librespot/pull/218). Now, volume is cached when the user supplies the `--cache` directory. `--initial-volume` overrides cached volume, which in turn overrides the default hard-coded volume. Currently, the volume is stored in a plaintext file containing only the (percentage) volume. In the future, it could be expanded into a config.json with other parameters as well, since I've largely copied the way that the credentials are stored in credentials.json. I don't know if the final commit (passing to `Spirc` and `SpircTask`) is the most elegant way to access the cache from `volume_to_mixer`, so I'm open to any improvements to that aspect. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-27 20:00:10 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/librespot#841
No description provided.