Struct cpal::EventLoop
[−]
[src]
pub struct EventLoop(_);
Collection of voices managed together.
Created with the new
method.
Methods
impl EventLoop
[src]
fn new() -> EventLoop
[src]
Initializes a new events loop.
fn build_voice(
&self,
endpoint: &Endpoint,
format: &Format
) -> Result<VoiceId, CreationError>
[src]
&self,
endpoint: &Endpoint,
format: &Format
) -> Result<VoiceId, CreationError>
Creates a new voice that will play on the given endpoint and with the given format.
On success, returns an identifier for the voice.
Can return an error if the endpoint is no longer valid, or if the format is not supported by the endpoint.
fn destroy_voice(&self, voice_id: VoiceId)
[src]
Destroys an existing voice.
Panic
If the voice doesn't exist, this function can either panic or be a no-op.
fn run<F>(&self, callback: F) -> ! where
F: FnMut(VoiceId, UnknownTypeBuffer) + Send,
[src]
F: FnMut(VoiceId, UnknownTypeBuffer) + Send,
Takes control of the current thread and processes the sounds.
Note: Since it takes control of the thread, this method is best called on a separate thread.
Whenever a voice 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.
fn play(&self, voice: VoiceId)
[src]
Instructs the audio device that it should start playing.
Has no effect is the voice was already playing.
Only call this after you have submitted some data, otherwise you may hear some glitches.
Panic
If the voice doesn't exist, this function can either panic or be a no-op.
fn pause(&self, voice: VoiceId)
[src]
Instructs the audio device that it should stop playing.
Has no effect is the voice was already paused.
If you call play
afterwards, the playback will resume where it was.
Panic
If the voice doesn't exist, this function can either panic or be a no-op.