Skip to main content

Module stream

Module stream 

Source
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), and Feeder::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_frames counts it.
  • The worker supplies a loop’s frames too, as LoopedRegion does, 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 feed the mixer reads, a Source that never waits.
Feeder
The end of a feed a worker writes.
LoopedRegion
A source that plays up to the end of a region, then from its start, for ever, for a worker to fill_from. restart gives 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 capacity frames of format (rounded up to a power of two): the end a worker writes, and the end the mixer reads.