Skip to contentSkip to conversation

noaudio: use audio_pcm_sw_read() in no_read()

PATCH In review Michael Walle 2 participants 6 messages Jan 3, 2011 – Jan 4, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 noaudio: use audio_pcm_sw_read() in no_read()

Instead of returning a self-calculated empty buffer use the proper method supplied by the audio subsystem. This will fix the return value of the no_read() function which otherwise returns too many samples because total_hw_samples_acquired isn't correctly accounted.

---
 audio/noaudio.c |    6 +-----
 1 files changed, 1 insertions(+), 5 deletions(-)
audio/noaudio.c +1 -5
index 8015858..e720327 100644
@@ -117,11 +117,7 @@ static int no_run_in (HWVoiceIn *hw)
 
 static int no_read (SWVoiceIn *sw, void *buf, int size)
 {
-    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);
-    audio_pcm_info_clear_buf (&sw->info, buf, to_clear);
-    return to_clear << sw->info.shift;
+    return audio_pcm_sw_read (sw, buf, size);
 }
 
 static int no_ctl_in (HWVoiceIn *hw, int cmd, ...)
Signature · 1 line
1.7.2.3
#1 lore raw
Quoted 4 lines · Michael Walle

Instead of returning a self-calculated empty buffer use the proper method supplied by the audio subsystem. This will fix the return value of the no_read() function which otherwise returns too many samples because total_hw_samples_acquired isn't correctly accounted.

What and how is incorrectly accounted? FWIW the audio_pcm_sw_read will perform useless resampling/mixing that's why custom code is used.

[..snip..]

Signature · 1 line
mailto:[email protected]
#2 lore raw
Quoted 8 lines · On Mon, 3 Jan 2011, 23:46:34 malc wrote:
Quoted 4 lines · Michael Walle

Instead of returning a self-calculated empty buffer use the proper method supplied by the audio subsystem. This will fix the return value of the no_read() function which otherwise returns too many samples because total_hw_samples_acquired isn't correctly accounted.

What and how is incorrectly accounted? FWIW the audio_pcm_sw_read will perform useless resampling/mixing that's why custom code is used.

total_hw_samples_acquired is never incremented (see audio_pcm_sw_read()). As a result the noaudio driver returns too many bytes per second.

Signature · 1 line
Michael
#3 lore raw
Quoted 7 lines · Michael Walle
Quoted 6 lines · On Mon, 3 Jan 2011, 23:46:34 malc wrote:
Quoted 4 lines · Michael Walle

Instead of returning a self-calculated empty buffer use the proper method supplied by the audio subsystem. This will fix the return value of the no_read() function which otherwise returns too many samples because total_hw_samples_acquired isn't correctly accounted.

Quoted 5 lines
Quoted 2 lines

What and how is incorrectly accounted? FWIW the audio_pcm_sw_read will perform useless resampling/mixing that's why custom code is used.

total_hw_samples_acquired is never incremented (see audio_pcm_sw_read()). As a result the noaudio driver returns too many bytes per second.

Okay, then the simpler patch should just increment it by amount in "total" variable.

Signature · 1 line
mailto:[email protected]
#4 lore raw

PATCH 1/1 noaudio: correctly account acquired samples

In reply to Michael Walle

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.

---
 audio/noaudio.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
audio/noaudio.c +3 -0
index 8015858..0304094 100644
@@ -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;
 }
Signature · 1 line
1.7.2.3
Applied
#5 lore raw

Re: [Qemu-devel] [PATCH] noaudio: correctly account acquired samples

Quoted 4 lines · Michael Walle

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.

Signature · 1 line
mailto:[email protected]