Skip to main content

Crate shuyi_sound_out

Crate shuyi_sound_out 

Source
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, and sound.js beside the page), which the page’s one thread feeds with blocks.
  • Output::null calls 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 handover that takes values out.
HandTo
The end of a handover that puts values in.
Output
An open output. The callback runs until it is dropped.
OutputConfig
What an output is asked for: the format of what its callback writes. The device’s own may differ, and convert makes up the difference.

Enums§

OutputError
Why an output didn’t open.

Functions§

handover
Makes the two ends of a hand-over with room for at least slots values waiting. Nothing is allocated or freed by HandTo::send or HandOut::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.