Struct sdl2::audio::AudioDevice [−][src]
pub struct AudioDevice<CB: AudioCallback> { /* fields omitted */ }
Expand description
Wraps SDL_AudioDeviceID
and owns the callback data used by the audio device.
Implementations
pub fn open_playback<'a, F, D>(
a: &AudioSubsystem,
device: D,
spec: &AudioSpecDesired,
get_callback: F
) -> Result<AudioDevice<CB>, String> where
F: FnOnce(AudioSpec) -> CB,
D: Into<Option<&'a str>>,
pub fn open_playback<'a, F, D>(
a: &AudioSubsystem,
device: D,
spec: &AudioSpecDesired,
get_callback: F
) -> Result<AudioDevice<CB>, String> where
F: FnOnce(AudioSpec) -> CB,
D: Into<Option<&'a str>>,
Opens a new audio device for playback (given the desired parameters and callback).
If you want to modify the callback-owned data at a later point (for example to update its data buffer) you’re likely to be interested in the lock method.
pub fn open_capture<'a, F, D>(
a: &AudioSubsystem,
device: D,
spec: &AudioSpecDesired,
get_callback: F
) -> Result<AudioDevice<CB>, String> where
F: FnOnce(AudioSpec) -> CB,
D: Into<Option<&'a str>>,
pub fn open_capture<'a, F, D>(
a: &AudioSubsystem,
device: D,
spec: &AudioSpecDesired,
get_callback: F
) -> Result<AudioDevice<CB>, String> where
F: FnOnce(AudioSpec) -> CB,
D: Into<Option<&'a str>>,
Opens a new audio device for capture (given the desired parameters and callback). Supported since SDL 2.0.5
If you want to modify the callback-owned data at a later point (for example to update its data buffer) you’re likely to be interested in the lock method.
Locks the audio device using SDL_LockAudioDevice
.
When the returned lock guard is dropped, SDL_UnlockAudioDevice
is
called.
Use this method to read and mutate callback data.
Closes the audio device and saves the callback data from being dropped.
Note that simply dropping AudioDevice
will close the audio device,
but the callback data will be dropped.