Expand description
Streams: what a worker hands the mixer, and what a voice reads it through.
A worker owns a decoder and a Feeder; the mixer owns the Feed, the
other end of a fixed ring of decoded frames. What the mixer holds of a stream
is that ring and a small buffer, however long the stream is.
The contract between them:
- The worker keeps the ring full ahead of the mix (
Feeder::fill_from), andFeeder::closes it after the last frame. - A read of an empty ring that isn’t closed is
Error::Underrun. The voice stays where it is and sounds nothing until frames come: an underrun delays a stream, and loses and repeats nothing.Mixer::underrun_framescounts it. - The worker supplies a loop’s frames too, as
LoopedRegiondoes, so that the way back to the start of a region is worked out and in the ring before the mix reaches the end of it.
Structs§
- Feed
- The end of a
feedthe mixer reads, aSourcethat never waits. - Feeder
- The end of a
feeda worker writes. - Looped
Region - A source that plays up to the end of a region, then from its start, for ever,
for a worker to
fill_from.restartgives the source from its first frame again, however that is done (a seek, or a new decoder over the same bytes), and the frames before the region are read and dropped: what comes out is sample-exact at the join whatever the decoder’s own pages are.
Functions§
- feed
- A ring of
capacityframes offormat(rounded up to a power of two): the end a worker writes, and the end the mixer reads.