Open tomaka opened 7 years ago
After some discussion this is a bad design. The decoding should be performed in an entirely separate thread in order to avoid problems if the harddrive isn't fast enough.
Of course we could also load data from the disk asynchronously, but that would be an enormous change.
Right now the engine loads samples "lazily" when the cpal backend requests them.
In other words, cpal tells rodio that samples are needed, and then only the samples are loaded from the audio file, converted, etc.
This is bad because passing samples to cpal should be the top priority in order to avoid a potential underflow.
I think we should add a
PrebufferedFilter
type that wraps around aSource
and allows pre-buffering some of the input. The engine would automatically wrap any source sent to it around aPrebufferedFilter
, and callpreload(...)
on the sources during downtimes.However this design requires some modifications in cpal in order to allow executing stuff during downtimes.