pub struct AudioHandle<T: AudioFormatNum + AudioSample> {
pub sample_rate: u32,
pub channels: u8,
pub samples: u16,
pub producer: AudioFrameProducer<T>,
/* private fields */
}Expand description
The struct for producing and controlling the audio playback.
It embeds the interconnected pair of carousel’s AudioFrameProducer with the
AudioFrameConsumer directly exposing the producer to the user. The consumer lives in the
SDL2 audio thread and is responsible for filling up the audio output buffer with sample data
sent from the producer.
The T parameter should be one of the sample primitives.
Fields§
§sample_rate: u32The audio sample frequency of the output stream.
channels: u8The number of audio channels in the output stream.
samples: u16The number of samples in the output audio buffer.
producer: AudioFrameProducer<T>The audio sample producer, interconnected with an audio consumer living in the audio thread.
Implementations§
Source§impl<T: AudioFormatNum + AudioSample> AudioHandle<T>
impl<T: AudioFormatNum + AudioSample> AudioHandle<T>
Sourcepub fn status(&self) -> AudioStatus
pub fn status(&self) -> AudioStatus
Returns the status of the audio device playback.
Sourcepub fn close(self) -> AudioFrameConsumer<T>
pub fn close(self) -> AudioFrameConsumer<T>
Closes audio playback and frees underlying resources. Returns the unwrapped frame consumer.
Sourcepub fn create(
sdl_context: &Sdl,
frame_duration_nanos: u32,
latency: usize,
) -> Result<Self, AudioHandleError>
pub fn create( sdl_context: &Sdl, frame_duration_nanos: u32, latency: usize, ) -> Result<Self, AudioHandleError>
Creates an instance of the AudioHandle from the provided SDL2 context.
The audio parameters used by default are the sample rate of 44100, 2 channels, and the output buffer size adjusted to the requested latency.
frame_duration_nanosis the duration in nanoseconds of the standard emulation frame.latencyis the requested audio latency; the actuallatencyargument passed to the create_carousel may be larger but never smaller than the provided one.
Sourcepub fn create_with_specs(
sdl_context: &Sdl,
desired_spec: AudioSpecDesired,
frame_duration_nanos: u32,
latency: usize,
) -> Result<Self, AudioHandleError>
pub fn create_with_specs( sdl_context: &Sdl, desired_spec: AudioSpecDesired, frame_duration_nanos: u32, latency: usize, ) -> Result<Self, AudioHandleError>
Creates an instance of the AudioHandle from the provided SDL2 context with the desired audio parameters.
The audio parameters used by default are the sample rate of 44100, 2 channels, and the output buffer size adjusted to the requested latency.
frame_duration_nanosis the duration in nanoseconds of the standard emulation frame.latencyis the requested audio latency; the actuallatencyargument passed to the create_carousel may be larger but never smaller than the provided one.desired_speccan be populated with the desired audio parameters.
Auto Trait Implementations§
impl<T> Freeze for AudioHandle<T>
impl<T> RefUnwindSafe for AudioHandle<T>where
T: RefUnwindSafe,
impl<T> !Send for AudioHandle<T>
impl<T> !Sync for AudioHandle<T>
impl<T> Unpin for AudioHandle<T>where
T: Unpin,
impl<T> UnwindSafe for AudioHandle<T>where
T: 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
Source§impl<S, T> IntoSample<S> for Twhere
S: FromSample<T>,
impl<S, T> IntoSample<S> for Twhere
S: FromSample<T>,
Source§fn into_sample(self) -> S
fn into_sample(self) -> S
S a sample type from self.