Struct sdl2::audio::AudioDevice
source · pub struct AudioDevice<CB: AudioCallback> { /* private fields */ }
Expand description
Wraps SDL_AudioDeviceID
and owns the callback data used by the audio device.
Implementations§
source§impl<CB: AudioCallback> AudioDevice<CB>
impl<CB: AudioCallback> AudioDevice<CB>
sourcepub fn open_playback<'a, F, D>(
a: &AudioSubsystem,
device: D,
spec: &AudioSpecDesired,
get_callback: F,
) -> Result<AudioDevice<CB>, String>
pub fn open_playback<'a, F, D>( a: &AudioSubsystem, device: D, spec: &AudioSpecDesired, get_callback: F, ) -> Result<AudioDevice<CB>, String>
Opens a new audio device for playback (given the desired parameters and callback).
sourcepub fn open_capture<'a, F, D>(
a: &AudioSubsystem,
device: D,
spec: &AudioSpecDesired,
get_callback: F,
) -> Result<AudioDevice<CB>, String>
pub fn open_capture<'a, F, D>( a: &AudioSubsystem, device: D, spec: &AudioSpecDesired, get_callback: F, ) -> Result<AudioDevice<CB>, String>
Opens a new audio device for capture (given the desired parameters and callback). Supported since SDL 2.0.5
pub fn subsystem(&self) -> &AudioSubsystem
pub fn spec(&self) -> &AudioSpec
pub fn status(&self) -> AudioStatus
sourcepub fn lock(&mut self) -> AudioDeviceLockGuard<'_, CB>
pub fn lock(&mut self) -> AudioDeviceLockGuard<'_, CB>
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.
sourcepub fn close_and_get_callback(self) -> CB
pub fn close_and_get_callback(self) -> CB
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.
Auto Trait Implementations§
impl<CB> Freeze for AudioDevice<CB>
impl<CB> RefUnwindSafe for AudioDevice<CB>where
CB: RefUnwindSafe,
impl<CB> !Send for AudioDevice<CB>
impl<CB> !Sync for AudioDevice<CB>
impl<CB> Unpin for AudioDevice<CB>
impl<CB> UnwindSafe for AudioDevice<CB>where
CB: 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
Mutably borrows from an owned value. Read more