pub struct Engine { /* private fields */ }Expand description
Implementations§
Source§impl Engine
impl Engine
Sourcepub async fn open(config: Config) -> Result<Self, Error>
pub async fn open(config: Config) -> Result<Self, Error>
Open the output device described by config.
Fails if there is no such device, or none at all. Later failures are the driver’s problem, not the caller’s: it reopens the device with backoff and existing sinks pick up where they left off.
Sourcepub fn sink(&self, input: Input) -> Result<Sink, Error>
pub fn sink(&self, input: Input) -> Result<Sink, Error>
Add a stream to the mix, taking PCM in the layout input describes.
Independent of the device: several sinks can play at different rates and layouts, and each is resampled and remixed to the device’s on its way to the mix. One device mixes up to 64 of them, past which this returns an error rather than handing back a sink that plays nothing.
Sourcepub fn observe(&self) -> Result<Observer, Error>
pub fn observe(&self) -> Result<Observer, Error>
Watch what this engine plays: every buffer the device pulls, counted in 128-frame quanta on the audio thread without blocking it.
Returns Error::Busy while another observer from this engine is alive.
Sourcepub fn canceller(&self, config: Config) -> Result<Control, Error>
pub fn canceller(&self, config: Config) -> Result<Control, Error>
Build echo-cancellation controls for this engine and one microphone.
Hand a clone to capture::Config::aec and
keep another for UI toggles. Only one control set can own this engine’s
reference; a second call returns Error::Busy until every control and
microphone attachment from the first is dropped.
Requires the capture and playback features.
Sourcepub async fn switch(&self, config: Config) -> Result<(), Error>
pub async fn switch(&self, config: Config) -> Result<(), Error>
Move playback to the device config names, or back to the system default
when Config::device is None.
Takes the same Config as open rather than a bare
device id, so a future playback option applies to a switch without
changing this signature.
Sinks survive the move: they keep the same handles and resample to the new device’s rate. Returns an error, and stays on no device, if the requested one can’t be opened. Also returns immediately with an error if the driver already has its bounded maximum of switches waiting.