[PR #393] [MERGED] Downloading files with dnamic block sizes for faster seek and playback #907

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

📋 Pull Request Information

Original PR: https://github.com/librespot-org/librespot/pull/393
Author: @kaymes
Created: 11/2/2019
Status: Merged
Merged: 11/12/2019
Merged by: @sashahilton00

Base: devHead: dynamic-blocks


📝 Commits (10+)

  • 333fc50 New file downloading mechanism
  • bf47ca7 some debug messages
  • 6545674 Merge remote-tracking branch 'origin/master' into dynamic-blocks
  • 971b2a9 Fix compile issues after merge
  • ba7d058 Merge remote-tracking branch 'origin/dev' into dynamic-blocks
  • 5ad6446 remove compiler warning
  • 1fcacf7 Merge branch 'dynamic-blocks' into comments
  • 216bdc0 Fix typo
  • 9f3e3d0 Fix infinite loop bug
  • af6e33b Remove commented line

📊 Changes

8 files changed (+1161 additions, -121 deletions)

View changed files

📝 .travis.yml (+1 -1)
📝 Cargo.lock (+1 -0)
📝 audio/Cargo.toml (+1 -0)
📝 audio/src/fetch.rs (+767 -113)
📝 audio/src/lib.rs (+9 -2)
audio/src/range_set.rs (+240 -0)
📝 core/src/channel.rs (+22 -0)
📝 playback/src/player.rs (+120 -5)

📄 Description

Quite a while ago, I analysed why librespot is slow when loading files and wrote up my findings in issue #306. Back then, I also started work on a new mechanism to download the files. Unfortunately, I got busy and forgot about it and never submitted it despite it being almost finished. Until today.

Here is my work on a new downloading strategy for librespot.

The idea is, that it uses dynamic block sizes. That is, blocks are small while seeking and during initial play and grow for downloading the grunt of the file. Also, while seeking in a file, it only downloads the requested blocks whereas while streaming, it reads ahead until the entire file is downloaded and placed in the cache.

I also implemented some heuristics based on the observed round-trip (ping) times to determine how much to buffer before playback.

Please test this version of the code.

The thing I'm most worried about is the possibility of not buffering enough because I can't exhaustively test this. This must be tested with different internet connections. If you notice the playback starting and then there's a short pause after which it resumes (a buffer under run), then the ping-time-buffer-heuristic must be adapted.


🔄 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/393 **Author:** [@kaymes](https://github.com/kaymes) **Created:** 11/2/2019 **Status:** ✅ Merged **Merged:** 11/12/2019 **Merged by:** [@sashahilton00](https://github.com/sashahilton00) **Base:** `dev` ← **Head:** `dynamic-blocks` --- ### 📝 Commits (10+) - [`333fc50`](https://github.com/librespot-org/librespot/commit/333fc5010c05b843fea62e7d85def603414d4e6c) New file downloading mechanism - [`bf47ca7`](https://github.com/librespot-org/librespot/commit/bf47ca70332fb2853f949566afdacb6f6476fcde) some debug messages - [`6545674`](https://github.com/librespot-org/librespot/commit/6545674a63e1c29c2fc33cc69d3ebb2959e4318a) Merge remote-tracking branch 'origin/master' into dynamic-blocks - [`971b2a9`](https://github.com/librespot-org/librespot/commit/971b2a9b9fdd91d3e9e68c2d51ae1190e7b67f2b) Fix compile issues after merge - [`ba7d058`](https://github.com/librespot-org/librespot/commit/ba7d05878488dd18db619a5b9bce2b4d771c5aed) Merge remote-tracking branch 'origin/dev' into dynamic-blocks - [`5ad6446`](https://github.com/librespot-org/librespot/commit/5ad6446616d203993ec3d4a0715418f170826f84) remove compiler warning - [`1fcacf7`](https://github.com/librespot-org/librespot/commit/1fcacf78cd4499b7d29bd79281051d5438a5dcb4) Merge branch 'dynamic-blocks' into comments - [`216bdc0`](https://github.com/librespot-org/librespot/commit/216bdc0f6fe8c38fc328a5715837cc4c6bd41e30) Fix typo - [`9f3e3d0`](https://github.com/librespot-org/librespot/commit/9f3e3d09d982667cf8e6439ffe3973706534a59e) Fix infinite loop bug - [`af6e33b`](https://github.com/librespot-org/librespot/commit/af6e33bfa012835077b066cb5bcab91658deb44c) Remove commented line ### 📊 Changes **8 files changed** (+1161 additions, -121 deletions) <details> <summary>View changed files</summary> 📝 `.travis.yml` (+1 -1) 📝 `Cargo.lock` (+1 -0) 📝 `audio/Cargo.toml` (+1 -0) 📝 `audio/src/fetch.rs` (+767 -113) 📝 `audio/src/lib.rs` (+9 -2) ➕ `audio/src/range_set.rs` (+240 -0) 📝 `core/src/channel.rs` (+22 -0) 📝 `playback/src/player.rs` (+120 -5) </details> ### 📄 Description Quite a while ago, I analysed why librespot is slow when loading files and wrote up my findings in issue #306. Back then, I also started work on a new mechanism to download the files. Unfortunately, I got busy and forgot about it and never submitted it despite it being almost finished. Until today. Here is my work on a new downloading strategy for librespot. The idea is, that it uses dynamic block sizes. That is, blocks are small while seeking and during initial play and grow for downloading the grunt of the file. Also, while seeking in a file, it only downloads the requested blocks whereas while streaming, it reads ahead until the entire file is downloaded and placed in the cache. I also implemented some heuristics based on the observed round-trip (ping) times to determine how much to buffer before playback. Please test this version of the code. The thing I'm most worried about is the possibility of not buffering enough because I can't exhaustively test this. This must be tested with different internet connections. If you notice the playback starting and then there's a short pause after which it resumes (a buffer under run), then the ping-time-buffer-heuristic must be adapted. --- <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:24 +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#907
No description provided.