Skip to main content

Module stream

Module stream 

Source
Expand description

Streaming HTTP → growing-buffer reader for the audio pipeline.

open_stream starts a background thread that downloads url via reqwest::blocking, appending chunks to a shared Vec<u8>. The StreamingReader returned immediately exposes that buffer as a Read + Seek handle that blocks only when the read position overtakes the download.

Keeping all bytes (never freeing) means backward seeks always succeed without re-fetching. Trade-off: memory grows with the file (~14–30 MB for a typical song), which is acceptable for a music player.

Playback starts as soon as 256 KB have been buffered (PREBUFFER_BYTES).

Structs§

StreamingReader
A Read + Seek handle to a streaming HTTP response.

Functions§

open_stream
Start streaming url in a background thread and return a reader that blocks only when the read position overtakes the download.