[][src]Struct spectrusty_audio::host::cpal::AudioHandle

pub struct AudioHandle<T: Sample + AudioSample> {
    pub sample_rate: u32,
    pub channels: u8,
    pub producer: AudioFrameProducer<T>,
    // some fields omitted
}

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 cpal 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][cpal::Sample].

Fields

sample_rate: u32

The audio sample frequency of the output stream.

channels: u8

The number of audio channels in the output stream.

producer: AudioFrameProducer<T>

The audio sample producer, interconnected with an audio consumer living in the audio thread.

Implementations

impl<T: Sample + AudioSample> AudioHandle<T>[src]

pub fn play(&self) -> Result<(), AudioHandleError>[src]

Starts playback of the audio device.

pub fn pause(&self) -> Result<(), AudioHandleError>[src]

Pauses playback of the audio device.

pub fn close(self)[src]

Closes audio playback and frees underlying resources.

pub fn create_with_device_and_config(
    device: &Device,
    config: &StreamConfig,
    frame_duration_nanos: u32,
    latency: usize
) -> Result<Self, AudioHandleError>
[src]

Creates an instance of the AudioHandle from the provided cpal device with the desired audio parameters.

  • config specifies the desired audio parameters.
  • frame_duration_nanos is the duration in nanoseconds of the standard emulation frame.
  • latency is the audio latency passed to the create_carousel.

Auto Trait Implementations

impl<T> !RefUnwindSafe for AudioHandle<T>

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>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<S, T> IntoSample<S> for T where
    S: FromSample<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.