mirror of
https://github.com/encounter/rust-sdl2.git
synced 2026-07-10 21:18:41 -07:00
Allow a null audio device to be specified
This commit is contained in:
+6
-2
@@ -262,11 +262,15 @@ impl AudioDevice {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn open(device: &str, iscapture: int, spec: &AudioSpec) -> Result<(AudioDevice, ~AudioSpec), ~str> {
|
||||
pub fn open(device: Option<&str>, iscapture: int, spec: &AudioSpec) -> Result<(AudioDevice, ~AudioSpec), ~str> {
|
||||
//! SDL_OpenAudioDevice
|
||||
let obtained = unsafe { mem::uninit::<AudioSpec>() };
|
||||
unsafe {
|
||||
let ret = ll::SDL_OpenAudioDevice(device.to_c_str().unwrap(),
|
||||
let device_c_str = match device {
|
||||
None => ptr::null(),
|
||||
Some(device) => device.to_c_str().unwrap(),
|
||||
};
|
||||
let ret = ll::SDL_OpenAudioDevice(device_c_str,
|
||||
iscapture as c_int,
|
||||
cast::transmute(spec),
|
||||
cast::transmute(&obtained),
|
||||
|
||||
Reference in New Issue
Block a user