From 35649c9af0322807a8b31b6c7038db2eb62abbf4 Mon Sep 17 00:00:00 2001 From: Henrik Lundberg Date: Wed, 16 Mar 2016 17:30:11 +0100 Subject: [PATCH] Set vector length after capturing buffers to it --- src/capture/capture.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/capture/capture.rs b/src/capture/capture.rs index 91ec729..597be8f 100644 --- a/src/capture/capture.rs +++ b/src/capture/capture.rs @@ -82,12 +82,15 @@ impl Capture { } /// Takes available samples out of the device. - pub fn take(&mut self) -> Result, Error> { - unsafe { - let mut result = Vec::with_capacity(self.len()); + pub fn take(&mut self) -> Result, Error> { + unsafe { + let length = self.len(); + let mut result = Vec::::with_capacity(length); al_try!(self, - alcCaptureSamples(self.as_mut_ptr(), result.as_mut_ptr() as *mut _, self.len() as ALCsizei)); + alcCaptureSamples(self.as_mut_ptr(), result.as_mut_ptr() as *mut _, length as ALCsizei)); + + result.set_len(length); Ok(result) }