[PR #580] [CLOSED] Refactor volume and cache #978

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

📋 Pull Request Information

Original PR: https://github.com/librespot-org/librespot/pull/580
Author: @Johannesd3
Created: 1/25/2021
Status: Closed

Base: devHead: refactor_cache


📝 Commits (5)

📊 Changes

13 files changed (+1493 additions, -1495 deletions)

View changed files

📝 Cargo.lock (+1263 -1305)
📝 audio/src/fetch.rs (+1 -1)
📝 connect/src/spirc.rs (+7 -37)
📝 core/src/authentication.rs (+1 -28)
📝 core/src/cache.rs (+107 -76)
📝 core/src/config.rs (+3 -3)
📝 core/src/volume.rs (+65 -22)
📝 playback/Cargo.toml (+1 -1)
📝 playback/src/mixer/alsamixer.rs (+3 -2)
📝 playback/src/mixer/mod.rs (+3 -1)
📝 playback/src/mixer/softmixer.rs (+4 -2)
📝 playback/src/player.rs (+4 -4)
📝 src/main.rs (+31 -13)

📄 Description

This PR suggest a refactor of Volume and Cache.

It replaces many occurences of u16 by Volume, which is a little used newtype for u16. (This would change public api in some places, but it could be easily reverted if it's not considered worth a breaking change).

The Cache was refactored completely. The logic to store and read Volume and Credentials in/from files was moved to Cache, which makes those independent from std::fs and std::io. As it is now possible to split audio and system cache, the paths in struct Cache were made optional. Also, error handling and logging was improved. It contains breaking changes as well, but there were also some in previous PRs.

I removed the additions made by #518, but if you're in favour of this PR, I would add them again before it is merged.

It would fix #578 by the way.


🔄 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/580 **Author:** [@Johannesd3](https://github.com/Johannesd3) **Created:** 1/25/2021 **Status:** ❌ Closed **Base:** `dev` ← **Head:** `refactor_cache` --- ### 📝 Commits (5) - [`8ebd482`](https://github.com/librespot-org/librespot/commit/8ebd4825c47ddc76d45cca2e999b1790e986a843) Use Volume struct throughout - [`5082642`](https://github.com/librespot-org/librespot/commit/5082642aedc1961e3525c589dd1b47d64dd33189) Refactored Cache - [`48e9b32`](https://github.com/librespot-org/librespot/commit/48e9b32187e642026986b09ee89939fd29effa6f) Made locations in cache optional - [`9749869`](https://github.com/librespot-org/librespot/commit/974986907c16584578d320e3601aebfba7eac373) Giving meaning to the Volume struct - [`ea1b87c`](https://github.com/librespot-org/librespot/commit/ea1b87c131202a51d1959e9a7c22cc1e9d1fa98c) Fix alsa mixer ### 📊 Changes **13 files changed** (+1493 additions, -1495 deletions) <details> <summary>View changed files</summary> 📝 `Cargo.lock` (+1263 -1305) 📝 `audio/src/fetch.rs` (+1 -1) 📝 `connect/src/spirc.rs` (+7 -37) 📝 `core/src/authentication.rs` (+1 -28) 📝 `core/src/cache.rs` (+107 -76) 📝 `core/src/config.rs` (+3 -3) 📝 `core/src/volume.rs` (+65 -22) 📝 `playback/Cargo.toml` (+1 -1) 📝 `playback/src/mixer/alsamixer.rs` (+3 -2) 📝 `playback/src/mixer/mod.rs` (+3 -1) 📝 `playback/src/mixer/softmixer.rs` (+4 -2) 📝 `playback/src/player.rs` (+4 -4) 📝 `src/main.rs` (+31 -13) </details> ### 📄 Description This PR suggest a refactor of Volume and Cache. It replaces many occurences of `u16` by `Volume`, which is a little used newtype for `u16`. (This would change public api in some places, but it could be easily reverted if it's not considered worth a breaking change). The `Cache` was refactored completely. The logic to store and read `Volume` and `Credentials` in/from files was moved to `Cache`, which makes those independent from `std::fs` and `std::io`. As it is now possible to split audio and system cache, the paths in `struct Cache` were made optional. Also, error handling and logging was improved. It contains breaking changes as well, but there were also some in previous PRs. I removed the additions made by #518, but if you're in favour of this PR, I would add them again before it is merged. It would fix #578 by the way. --- <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:41 +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#978
No description provided.