[GH-ISSUE #1231] Configurable MINIMUN_DOWNLOAD_SIZE / audio fetch parameters #563

Closed
opened 2026-02-27 19:31:18 +03:00 by kerem · 3 comments
Owner

Originally created by @lelloman on GitHub (Dec 11, 2023).
Original GitHub issue: https://github.com/librespot-org/librespot/issues/1231

I'm manually changing MINIMUM_DOWNLOAD_SIZE and DOWNLOAD_TIMEOUT values in audio/src/fetch/mod.rs, this is because I noticed that the server was shutting the transmission if the pre-fetch was a bit too aggressive. Tuning MINIMUM_DOWNLOAD_SIZE, in the source code, solved the issue.

I think it would be beneficial if the constants in fetch/mod.rs could be configurable, something like a static configuration struct.
The gist of the change would be:

pub struct AudioFetchParams {
   pub minimum_download_size: usize
   // etc...
}

impl Default for AudioFetchParams {
    // current values here
}

impl AudioFetchParams {
    pub init(params: AudioFetchParams) -> Result<(), AudioFetchParams> // set to static OnceLock
    pub get() -> &'static AudioFetchParams // get or init with default
}

If the feature seems acceptable, I'd be happy to open a PR and eventually iterate on the implementation there.

Originally created by @lelloman on GitHub (Dec 11, 2023). Original GitHub issue: https://github.com/librespot-org/librespot/issues/1231 I'm manually changing MINIMUM_DOWNLOAD_SIZE and DOWNLOAD_TIMEOUT values in audio/src/fetch/mod.rs, this is because I noticed that the server was shutting the transmission if the pre-fetch was a bit too aggressive. Tuning MINIMUM_DOWNLOAD_SIZE, in the source code, solved the issue. I think it would be beneficial if the constants in fetch/mod.rs could be configurable, something like a static configuration struct. The gist of the change would be: ``` pub struct AudioFetchParams { pub minimum_download_size: usize // etc... } impl Default for AudioFetchParams { // current values here } impl AudioFetchParams { pub init(params: AudioFetchParams) -> Result<(), AudioFetchParams> // set to static OnceLock pub get() -> &'static AudioFetchParams // get or init with default } ``` If the feature seems acceptable, I'd be happy to open a PR and eventually iterate on the implementation there.
kerem 2026-02-27 19:31:18 +03:00
Author
Owner

@kingosticks commented on GitHub (Dec 11, 2023):

Can you add a bit more detail in case anyone else runs into this? What librespot error messages did you see? Is this for music or podcasts? What values did you have to use? Maybe we should also adjust the defaults.

<!-- gh-comment-id:1849860473 --> @kingosticks commented on GitHub (Dec 11, 2023): Can you add a bit more detail in case anyone else runs into this? What librespot error messages did you see? Is this for music or podcasts? What values did you have to use? Maybe we should also adjust the defaults.
Author
Owner

@lelloman commented on GitHub (Dec 11, 2023):

I'm reading AudioFile directly, feeding the audio to my own player, and read would return AudioFileError::WaitTimeout after a while, content is always music. With MINIMUM_DOWNLOAD_SIZE: usize = 48 * 1024; I don't get the error anymore, but the network transfer speed is a bit lower (from ~1200 to ~750 Kb/s). I'm not really sure that changing the defaults is really needed as my usecase is somewhat convoluted, although still very educational.

I think that giving the possibility to tune those parameters at runtime would already be a nice improvement, one could experiment with those parameters to see what gives the best user experience, and if a usecase arises that needs tuning, no need to compile from source.

<!-- gh-comment-id:1850096007 --> @lelloman commented on GitHub (Dec 11, 2023): I'm reading AudioFile directly, feeding the audio to my own player, and `read` would return `AudioFileError::WaitTimeout` after a while, content is always music. With `MINIMUM_DOWNLOAD_SIZE: usize = 48 * 1024;` I don't get the error anymore, but the network transfer speed is a bit lower (from ~1200 to ~750 Kb/s). I'm not really sure that changing the defaults is really needed as my usecase is somewhat convoluted, although still very educational. I think that giving the possibility to tune those parameters at runtime would already be a nice improvement, one could experiment with those parameters to see what gives the best user experience, and if a usecase arises that needs tuning, no need to compile from source.
Author
Owner

@roderickvd commented on GitHub (Dec 15, 2023):

I think it can be useful. I have no idea how well the current default will work for, I don’t know, cell phones in the jungle or satlink to the space station. Kidding aside, I see there can be edges cases that someone would want to tune.

On the defaults I want to add: in v0.5 I rewrote huge parts of it and there was little feedback on it. Could very well be that the defaults should be improved, I don’t know.

<!-- gh-comment-id:1857740380 --> @roderickvd commented on GitHub (Dec 15, 2023): I think it can be useful. I have no idea how well the current default will work for, I don’t know, cell phones in the jungle or satlink to the space station. Kidding aside, I see there can be edges cases that someone would want to tune. On the defaults I want to add: in v0.5 I rewrote huge parts of it and there was little feedback on it. Could very well be that the defaults should be improved, I don’t know.
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#563
No description provided.