[PR #218] [CLOSED] Persist software volume across restarts #840

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

📋 Pull Request Information

Original PR: https://github.com/librespot-org/librespot/pull/218
Author: @bricedp
Created: 5/10/2018
Status: Closed

Base: masterHead: persist-volume


📝 Commits (6)

  • e23c233 add persist-volume to command line options
  • fa66dd3 add persist-volume to ConnectConfig
  • f2be053 import fs, io, path modules to read and write volume persistence file
  • fed8988 pass persist_volume to volume_to_mixer function calls
  • 9cd9737 add logic to read and write persistent volume
  • 41480e7 rustfmt changes

📊 Changes

5 files changed (+72 additions, -14 deletions)

View changed files

📝 connect/src/spirc.rs (+37 -8)
📝 core/src/config.rs (+1 -0)
📝 examples/play.rs (+1 -1)
📝 playback/src/audio_backend/jackaudio.rs (+4 -2)
📝 src/main.rs (+29 -3)

📄 Description

This pull request adds the ability to persist the software volume across restarts of librespot. A user can now specify a file path using the --persist-volume flag where the volume will be written to disk. If the file exists, the volume will be read from it and it will override the --initial-volume value. If not, it will be written upon the first connection of a client. This way, --initial-volume can still be used to set the volume for the first run of librespot, after which the persistent volume will take precedence.

For example, librespot --initial-volume 25 --persist-volume /tmp/librespot.vol will start at 25%, but all future runs of the program will read the most recent volume from /tmp/librespot.vol.

In the event that the file cannot be written to or read from, the current logic intends for librespot to fail fast and hard, so that the user is made aware and not led to believe that the volume is being persisted when in fact it isn't.

Builds against the latest nightly version of rust (1.27.0) pass without errors or warnings, and rustfmt has been used to standardize the code. Please let me know if you need me to make any changes. Rust is a relatively new language to me, so I am not sure if the unwrap() and clone() calls are considered best practice as implemented here.


🔄 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/218 **Author:** [@bricedp](https://github.com/bricedp) **Created:** 5/10/2018 **Status:** ❌ Closed **Base:** `master` ← **Head:** `persist-volume` --- ### 📝 Commits (6) - [`e23c233`](https://github.com/librespot-org/librespot/commit/e23c2336c9408ebb4566d41f05efb126c1afd0c6) add persist-volume to command line options - [`fa66dd3`](https://github.com/librespot-org/librespot/commit/fa66dd312bf0906403df1f8fdae9008d69b91076) add persist-volume to ConnectConfig - [`f2be053`](https://github.com/librespot-org/librespot/commit/f2be0533f349e899e6f6240b5c77eacb42ac2422) import fs, io, path modules to read and write volume persistence file - [`fed8988`](https://github.com/librespot-org/librespot/commit/fed89882d5a57b0c9d86df33018dce4f68835743) pass persist_volume to volume_to_mixer function calls - [`9cd9737`](https://github.com/librespot-org/librespot/commit/9cd9737613a9a47f2537a930b6c4ddc6c61bdddc) add logic to read and write persistent volume - [`41480e7`](https://github.com/librespot-org/librespot/commit/41480e708524462451b8bd5778235eb759ec0261) rustfmt changes ### 📊 Changes **5 files changed** (+72 additions, -14 deletions) <details> <summary>View changed files</summary> 📝 `connect/src/spirc.rs` (+37 -8) 📝 `core/src/config.rs` (+1 -0) 📝 `examples/play.rs` (+1 -1) 📝 `playback/src/audio_backend/jackaudio.rs` (+4 -2) 📝 `src/main.rs` (+29 -3) </details> ### 📄 Description This pull request adds the ability to persist the software volume across restarts of librespot. A user can now specify a file path using the `--persist-volume` flag where the volume will be written to disk. If the file exists, the volume will be read from it and it will override the `--initial-volume` value. If not, it will be written upon the first connection of a client. This way, `--initial-volume` can still be used to set the volume for the first run of librespot, after which the persistent volume will take precedence. For example, `librespot --initial-volume 25 --persist-volume /tmp/librespot.vol` will start at 25%, but all future runs of the program will read the most recent volume from /tmp/librespot.vol. In the event that the file cannot be written to or read from, the current logic intends for librespot to fail fast and hard, so that the user is made aware and not led to believe that the volume is being persisted when in fact it isn't. Builds against the latest nightly version of rust (1.27.0) pass without errors or warnings, and rustfmt has been used to standardize the code. Please let me know if you need me to make any changes. Rust is a relatively new language to me, so I am not sure if the `unwrap()` and `clone()` calls are considered best practice as implemented here. --- <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:09 +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#840
No description provided.