Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions src/capture/capture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,15 @@ impl<T: Sample> Capture<T> {
}

/// Takes available samples out of the device.
pub fn take(&mut self) -> Result<Vec<T>, Error> {
unsafe {
let mut result = Vec::with_capacity(self.len());
pub fn take(&mut self) -> Result<Vec<T>, Error> {
unsafe {
let length = self.len();
let mut result = Vec::<T>::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)
}
Expand Down