Configurable MINIMUN_DOWNLOAD_SIZE / audio fetch parameters
lelloman opened this issue · comments
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.
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.
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.
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.