Expand description
Sound output: hands a mix to the system and nothing else. Output calls a
callback for samples, from the system’s audio thread where there is one, and the
callback knows nothing of where they go.
- On Windows it is CPAL (
windows): it takes the device’s format, converts at the boundary (convert) and comes back on the new default device when one goes away. - In the browser it is a worklet of our own (
web, andsound.jsbeside the page), which the page’s one thread feeds with blocks. Output::nullcalls the callback on a timer and discards what it gives: for tests, and a machine with no sound, where a caller picks it over a crash.
handover moves what can’t cross as plain data to a thread that may neither
allocate nor free. Everything that isn’t safe code is in sys.
Modules§
- convert
- How samples become what a device takes.
Structs§
- HandOut
- The end of a
handoverthat takes values out. - HandTo
- The end of a
handoverthat puts values in. - Output
- An open output. The callback runs until it is dropped.
- Output
Config - What an output is asked for: the format of what its callback writes. The device’s
own may differ, and
convertmakes up the difference.
Enums§
- Output
Error - Why an output didn’t open.
Functions§
- handover
- Makes the two ends of a hand-over with room for at least
slotsvalues waiting. Nothing is allocated or freed byHandTo::sendorHandOut::take: a value’s box goes from one thread to the other, and whoever ends up with it frees it, so the end on an audio thread sends each box back rather than dropping it.