Struct awedio::sounds::wrappers::CompletionNotifier
source · pub struct CompletionNotifier<S: Sound> { /* private fields */ }
Expand description
Notify via a std::sync::mpsc::Receiver when the contained Sound has Finished. A single message is sent when the sound has completed.
If the Sound is dropped before it returned Finished then the receiver will return an error. The contained Sound pausing or yielding an error does not count as completion.
See also crate::Sound::with_async_completion_notifier See also super::AsyncCompletionNotifier
Implementations§
Trait Implementations§
source§impl<S> Sound for CompletionNotifier<S>where
S: Sound,
impl<S> Sound for CompletionNotifier<S>where
S: Sound,
source§fn channel_count(&self) -> u16
fn channel_count(&self) -> u16
Returns the number of channels.
source§fn sample_rate(&self) -> u32
fn sample_rate(&self) -> u32
Returns the number of samples per second for each channel for this sound
(e.g. 44,100).
source§fn next_sample(&mut self) -> Result<NextSample, Error>
fn next_sample(&mut self) -> Result<NextSample, Error>
Retrieve the next sample or notification if something has changed.
The first sample is for the first channel and the second is the for
second and so on until channel_count and then wraps back to the first
channel. If any NextSample variant besides
Sample
is returned then
the following NextSample::Sample
is for the first channel. If a Sound
has returned Paused
it is expected that the consumer will call
next_sample again in the future. If a Sound has returned Finished
it
is not expected for the consumer to call next_sample again but if called
Finished
will normally be returned again. After Finished has been
returned, channel_count() and sample_rate() may return different values
without MetadataChanged being returned. Read moresource§fn on_start_of_batch(&mut self)
fn on_start_of_batch(&mut self)
Called whenever a new batch of audio samples is requested by the
backend. Read more
source§fn next_frame(&mut self) -> Result<Vec<i16>, Result<NextSample, Error>>
fn next_frame(&mut self) -> Result<Vec<i16>, Result<NextSample, Error>>
Returns the next sample for all channels. Read more
source§fn append_next_frame_to(
&mut self,
samples: &mut Vec<i16>,
) -> Result<(), Result<NextSample, Error>>
fn append_next_frame_to( &mut self, samples: &mut Vec<i16>, ) -> Result<(), Result<NextSample, Error>>
Same as
next_frame
but samples are appended into an existing Vec. Read moresource§fn into_memory_sound(self) -> Result<MemorySound, Error>where
Self: Sized,
fn into_memory_sound(self) -> Result<MemorySound, Error>where
Self: Sized,
Read the entire sound into memory. MemorySound can be cloned for
efficient reuse. See MemorySound::from_sound.
source§fn loop_from_memory(self) -> Result<MemorySound, Error>where
Self: Sized,
fn loop_from_memory(self) -> Result<MemorySound, Error>where
Self: Sized,
Read the entire sound into memory and loop indefinitely. Read more
source§fn controllable(self) -> (Controllable<Self>, Controller<Self>)where
Self: Sized,
fn controllable(self) -> (Controllable<Self>, Controller<Self>)where
Self: Sized,
Allow this sound to be controlled after it has started playing with a
Controller
. Read moresource§fn with_async_completion_notifier(
self,
) -> (AsyncCompletionNotifier<Self>, Receiver<()>)where
Self: Sized,
fn with_async_completion_notifier(
self,
) -> (AsyncCompletionNotifier<Self>, Receiver<()>)where
Self: Sized,
Get notified via a tokio::sync::oneshot::Receiver when this sound
has Finished.
source§fn with_completion_notifier(self) -> (CompletionNotifier<Self>, Receiver<()>)where
Self: Sized,
fn with_completion_notifier(self) -> (CompletionNotifier<Self>, Receiver<()>)where
Self: Sized,
Get notified via a std::sync::mpsc::Receiver when this sound
has Finished.
source§fn with_adjustable_volume(self) -> AdjustableVolume<Self>where
Self: Sized,
fn with_adjustable_volume(self) -> AdjustableVolume<Self>where
Self: Sized,
Allow the volume of the sound to be adjustable with
set_volume
.source§fn with_adjustable_volume_of(
self,
volume_adjustment: f32,
) -> AdjustableVolume<Self>where
Self: Sized,
fn with_adjustable_volume_of(
self,
volume_adjustment: f32,
) -> AdjustableVolume<Self>where
Self: Sized,
Allow the volume of the sound to be adjustable with
set_volume
and set
the initial volume adjustment.source§fn with_adjustable_speed(self) -> AdjustableSpeed<Self>where
Self: Sized,
fn with_adjustable_speed(self) -> AdjustableSpeed<Self>where
Self: Sized,
Allow the speed of the sound to be adjustable with
set_speed
. Read moresource§fn with_adjustable_speed_of(
self,
speed_adjustment: f32,
) -> AdjustableSpeed<Self>where
Self: Sized,
fn with_adjustable_speed_of(
self,
speed_adjustment: f32,
) -> AdjustableSpeed<Self>where
Self: Sized,
Allow the speed of the sound to be adjustable with
set_speed
and set
the initial speed adjustment. Read moresource§fn pausable(self) -> Pausable<Self>where
Self: Sized,
fn pausable(self) -> Pausable<Self>where
Self: Sized,
Allow for the sound to be pausable with
set_paused
. Starts unpaused.source§fn paused(self) -> Pausable<Self>where
Self: Sized,
fn paused(self) -> Pausable<Self>where
Self: Sized,
Allow for the sound to be pausable with
set_paused
. Starts paused.source§fn finish_after(self, duration: Duration) -> FinishAfter<Self>where
Self: Sized,
fn finish_after(self, duration: Duration) -> FinishAfter<Self>where
Self: Sized,
Play the first
duration
of the sound, then finish even if samples
remain. Read moresource§impl<S> Wrapper for CompletionNotifier<S>where
S: Sound,
impl<S> Wrapper for CompletionNotifier<S>where
S: Sound,
Auto Trait Implementations§
impl<S> Freeze for CompletionNotifier<S>where
S: Freeze,
impl<S> RefUnwindSafe for CompletionNotifier<S>where
S: RefUnwindSafe,
impl<S> Send for CompletionNotifier<S>
impl<S> Sync for CompletionNotifier<S>where
S: Sync,
impl<S> Unpin for CompletionNotifier<S>where
S: Unpin,
impl<S> UnwindSafe for CompletionNotifier<S>where
S: UnwindSafe,
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
Mutably borrows from an owned value. Read more
source§impl<S> ClearSounds for S
impl<S> ClearSounds for S
source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
source§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
source§impl<S> SetPaused for S
impl<S> SetPaused for S
source§fn set_paused(&mut self, paused: bool)
fn set_paused(&mut self, paused: bool)
Pause or unpause the sound.
source§impl<S> SetVolume for S
impl<S> SetVolume for S
source§fn set_volume(&mut self, new: f32)
fn set_volume(&mut self, new: f32)
Change the loudness. Read more