Patchwork noaudio: correctly account acquired samples

login
register
mail settings
Submitter Michael Walle
Date Jan. 4, 2011, 12:48 a.m.
Message ID <1294102135-14034-1-git-send-email-michael@walle.cc>
Download mbox | patch
Permalink /patch/77359/
State New
Headers show

Comments

Michael Walle - Jan. 4, 2011, 12:48 a.m.
This will fix the return value of the function which otherwise returns too
many samples because sw->total_hw_samples_acquired isn't correctly
accounted.

Signed-off-by: Michael Walle <michael@walle.cc>
---
 audio/noaudio.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
malc - Jan. 4, 2011, 12:54 a.m.
On Tue, 4 Jan 2011, Michael Walle wrote:

> This will fix the return value of the function which otherwise returns too
> many samples because sw->total_hw_samples_acquired isn't correctly
> accounted.
> 

Applied, thanks.

Patch

diff --git a/audio/noaudio.c b/audio/noaudio.c
index 8015858..0304094 100644
--- a/audio/noaudio.c
+++ b/audio/noaudio.c
@@ -117,9 +117,12 @@  static int no_run_in (HWVoiceIn *hw)
 
 static int no_read (SWVoiceIn *sw, void *buf, int size)
 {
+    /* use custom code here instead of audio_pcm_sw_read() to avoid
+     * useless resampling/mixing */
     int samples = size >> sw->info.shift;
     int total = sw->hw->total_samples_captured - sw->total_hw_samples_acquired;
     int to_clear = audio_MIN (samples, total);
+    sw->total_hw_samples_acquired += total;
     audio_pcm_info_clear_buf (&sw->info, buf, to_clear);
     return to_clear << sw->info.shift;
 }