Expand description
Commands from another thread: a fixed ring of plain data, one writer and one
reader, with no lock, no allocation and no unsafe.
A ring’s slots are AtomicU32s and a command is written as words, so nothing
has to be shared but atomics. The writer stores a slot’s words and then the head
with Release, the reader loads the head with Acquire and then the words, and
the same the other way for the tail. Only loads and stores: they are what the
smallest targets have.
Mixer::remote makes the two ends. The Remote on the game’s side decides
which voice a play goes to, so it can answer Full on the spot, and the
Inbox on the audio thread applies what came and says which voices ended.
A Pcm or a source can’t go through as words: a backend gives them
to the mixer (Mixer::add_sound, Mixer::add_stream) before the mixer goes
to the audio thread, or across by a route of its own.
Structs§
- Inbox
- What the audio thread calls before each
Mixer::render. - Remote
- The mixer as a game’s thread sees it, when the mixer is on the audio thread: the same operations, none of which waits.