[][src]Struct cpal::EventLoop

pub struct EventLoop(_);

Collection of voices managed together.

Created with the new method.

Methods

impl EventLoop[src]

pub fn new() -> EventLoop[src]

Initializes a new events loop.

pub fn build_input_stream(
    &self,
    device: &Device,
    format: &Format
) -> Result<StreamId, CreationError>
[src]

Creates a new input stream that will run from the given device and with the given format.

On success, returns an identifier for the stream.

Can return an error if the device is no longer valid, or if the input stream format is not supported by the device.

pub fn build_output_stream(
    &self,
    device: &Device,
    format: &Format
) -> Result<StreamId, CreationError>
[src]

Creates a new output stream that will play on the given device and with the given format.

On success, returns an identifier for the stream.

Can return an error if the device is no longer valid, or if the output stream format is not supported by the device.

pub fn play_stream(&self, stream: StreamId)[src]

Instructs the audio device that it should start playing the stream with the given ID.

Has no effect is the stream was already playing.

Only call this after you have submitted some data, otherwise you may hear some glitches.

Panic

If the stream does not exist, this function can either panic or be a no-op.

pub fn pause_stream(&self, stream: StreamId)[src]

Instructs the audio device that it should stop playing the stream with the given ID.

Has no effect is the stream was already paused.

If you call play afterwards, the playback will resume where it was.

Panic

If the stream does not exist, this function can either panic or be a no-op.

pub fn destroy_stream(&self, stream_id: StreamId)[src]

Destroys an existing stream.

Panic

If the stream does not exist, this function can either panic or be a no-op.

pub fn run<F>(&self, callback: F) -> ! where
    F: FnMut(StreamId, StreamData) + Send
[src]

Takes control of the current thread and begins the stream processing.

Note: Since it takes control of the thread, this method is best called on a separate thread.

Whenever a stream needs to be fed some data, the closure passed as parameter is called. You can call the other methods of EventLoop without getting a deadlock.

Auto Trait Implementations

impl Send for EventLoop

impl Sync for EventLoop

Blanket Implementations

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

impl<T> From<T> for 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.

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

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

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