From 9598f68d3c2d834eba3277077d085e8bdb8e9649 Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Mon, 15 Dec 2014 16:06:37 +0100 Subject: [PATCH] Minor fixes --- src/lib.rs | 9 +++++++-- src/wasapi/mod.rs | 5 +++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 769d297..05141e0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -186,8 +186,13 @@ impl<'a, T> Buffer<'a, T> { /// Iterator over the samples of the buffer. impl<'a, 'b, T> Iterator<&'b mut T> for SamplesIter<'a, 'b, T> { fn next(&mut self) -> Option<&'b mut T> { - *self.0 += 1; - self.1.next() + match self.1.next() { + Some(v) => { + *self.0 += 1; + Some(v) + }, + None => None + } } } diff --git a/src/wasapi/mod.rs b/src/wasapi/mod.rs index 3ae8ef7..2feaa77 100644 --- a/src/wasapi/mod.rs +++ b/src/wasapi/mod.rs @@ -4,6 +4,7 @@ extern crate winapi; use std::{mem, ptr}; use std::c_vec::CVec; +// TODO: determine if should be NoSend or not pub struct Channel { audio_client: *mut winapi::IAudioClient, render_client: *mut winapi::IAudioRenderClient, @@ -58,7 +59,7 @@ impl Channel { if frames_available == 0 { // TODO: - ::std::io::timer::sleep(::std::time::duration::Duration::milliseconds(5)); + ::std::io::timer::sleep(::std::time::duration::Duration::milliseconds(1)); continue; } @@ -116,7 +117,7 @@ impl<'a, T> Buffer<'a, T> { // releasing buffer unsafe { let f = self.render_client.as_mut().unwrap().lpVtbl.as_ref().unwrap().ReleaseBuffer; - let hresult = f(self.render_client, self.frames, 0); + let hresult = f(self.render_client, elements_written as u32, 0); check_result(hresult).unwrap(); if self.start_on_drop {