From a3f7ea86c0c94177930cc60a78b0ea1da2f8d10c Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Sun, 4 May 2014 11:54:32 -0700 Subject: [PATCH] Allow a null audio device to be specified --- src/sdl2/audio.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/sdl2/audio.rs b/src/sdl2/audio.rs index e573e7fe..8abe5919 100644 --- a/src/sdl2/audio.rs +++ b/src/sdl2/audio.rs @@ -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::() }; 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),