From d6470de74ccb8c89a50d12b652075ddcdeb54888 Mon Sep 17 00:00:00 2001 From: mitchmindtree Date: Sat, 28 Feb 2015 06:43:15 +1100 Subject: [PATCH] Properly shutdown the AudioUnit on drop --- src/core_audio/mod.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/core_audio/mod.rs b/src/core_audio/mod.rs index da09123..414138a 100644 --- a/src/core_audio/mod.rs +++ b/src/core_audio/mod.rs @@ -72,6 +72,15 @@ impl Voice { } } +impl Drop for Voice { + fn drop(&mut self) { + unsafe { + check_errors(au::AudioOutputUnitStop(*self.audio_unit)).unwrap(); + check_errors(au::AudioUnitUninitialize(*self.audio_unit)).unwrap(); + } + } +} + impl<'a, T> Buffer<'a, T> { pub fn get_buffer<'b>(&'b mut self) -> &'b mut [T] { &mut self.samples[..]