pub struct Audio { /* private fields */ }Expand description
The output device and the sounds playing on it. The runner owns
one; a host driving a core itself makes one with Audio::new and
calls Audio::apply and Audio::poll_ended on its own turns.
Implementations§
Source§impl Audio
impl Audio
Sourcepub fn warm(&mut self)
pub fn warm(&mut self)
Starts opening the device if nothing has yet. Cheap to call every frame; the driver calls it once the session holds a sound, so the device is open by the time a click asks for one.
Sourcepub fn apply(
&mut self,
cmds: Vec<AudioCommand>,
resources: &SharedResources,
) -> Answered
pub fn apply( &mut self, cmds: Vec<AudioCommand>, resources: &SharedResources, ) -> Answered
Applies queued commands to the device; while it is still opening they wait, in order. Returns what the device answered back: the stops that landed on a sound still playing and the plays it would not take. A command that waited for the device reports on the apply that flushes it, not the one that queued it.
Sourcepub fn poll_ended(&mut self) -> Vec<PlaybackId>
pub fn poll_ended(&mut self) -> Vec<PlaybackId>
Playbacks that finished on their own since the last poll
(stopped ones were already forgotten by Stop). Also where a
command that waited for the device starts, since the driver
polls while anything is active.
Sourcepub fn holds_device(&self) -> bool
pub fn holds_device(&self) -> bool
Whether the device is open or opening. An open output stream is a real-time thread that runs whether or not anything is playing, so a driver closes it after a quiet spell.
Sourcepub fn close(&mut self)
pub fn close(&mut self)
Lets the output device go; the decoded-sound cache stays, so the
next play pays the open again but not the decode. Does nothing
while anything is playing or waiting, or while the device is
still opening: call it once Self::active has been false for
a while, and again if it did not take.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Audio
impl !Send for Audio
impl !Sync for Audio
impl !UnwindSafe for Audio
impl Freeze for Audio
impl Unpin for Audio
impl UnsafeUnpin for Audio
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.