diff --git a/examples/audio-queue-squarewave.rs b/examples/audio-queue-squarewave.rs index 22d237bec8..781733e529 100644 --- a/examples/audio-queue-squarewave.rs +++ b/examples/audio-queue-squarewave.rs @@ -36,7 +36,7 @@ fn main() -> Result<(), String> { let target_bytes = 48_000 * 4; let wave = gen_wave(target_bytes); - device.queue(&wave); + device.queue(&wave)?; // Start playback device.resume(); diff --git a/src/sdl2/audio.rs b/src/sdl2/audio.rs index 07dd6d3b7e..d5484e56f0 100644 --- a/src/sdl2/audio.rs +++ b/src/sdl2/audio.rs @@ -750,7 +750,7 @@ impl<'a, Channel: AudioFormatNum> AudioQueue { /// Adds data to the audio queue. #[doc(alias = "SDL_QueueAudio")] - pub fn queue(&self, data: &[Channel]) -> bool { + pub fn queue(&self, data: &[Channel]) -> Result<(), String> { let result = unsafe { sys::SDL_QueueAudio( self.device_id.id(), @@ -758,7 +758,11 @@ impl<'a, Channel: AudioFormatNum> AudioQueue { (data.len() * mem::size_of::()) as u32, ) }; - result == 0 + if result == 0 { + Ok(()) + } else { + Err(get_error()) + } } #[doc(alias = "SDL_GetQueuedAudioSize")]