qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] noaudio: use audio_pcm_sw_read() in no_read()
@ 2011-01-03 22:40 Michael Walle
  2011-01-03 22:46 ` malc
  0 siblings, 1 reply; 6+ messages in thread
From: Michael Walle @ 2011-01-03 22:40 UTC (permalink / raw)
  To: qemu-devel; +Cc: 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.

Signed-off-by: Michael Walle <michael@walle.cc>
---
 audio/noaudio.c |    6 +-----
 1 files changed, 1 insertions(+), 5 deletions(-)

diff --git a/audio/noaudio.c b/audio/noaudio.c
index 8015858..e720327 100644
--- a/audio/noaudio.c
+++ b/audio/noaudio.c
@@ -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, ...)
-- 
1.7.2.3

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCH] noaudio: use audio_pcm_sw_read() in no_read()
  2011-01-03 22:40 [Qemu-devel] [PATCH] noaudio: use audio_pcm_sw_read() in no_read() Michael Walle
@ 2011-01-03 22:46 ` malc
  2011-01-03 22:59   ` Michael Walle
  0 siblings, 1 reply; 6+ messages in thread
From: malc @ 2011-01-03 22:46 UTC (permalink / raw)
  To: Michael Walle; +Cc: qemu-devel

On Mon, 3 Jan 2011, Michael Walle wrote:

> 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..]

-- 
mailto:av1474@comtv.ru

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCH] noaudio: use audio_pcm_sw_read() in no_read()
  2011-01-03 22:46 ` malc
@ 2011-01-03 22:59   ` Michael Walle
  2011-01-04  0:05     ` malc
  2011-01-04  0:48     ` [Qemu-devel] [PATCH] noaudio: correctly account acquired samples Michael Walle
  0 siblings, 2 replies; 6+ messages in thread
From: Michael Walle @ 2011-01-03 22:59 UTC (permalink / raw)
  To: malc; +Cc: qemu-devel

On Mon, 3 Jan 2011, 23:46:34 malc wrote:
> On Mon, 3 Jan 2011, Michael Walle wrote:
> > 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.

-- 
Michael

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCH] noaudio: use audio_pcm_sw_read() in no_read()
  2011-01-03 22:59   ` Michael Walle
@ 2011-01-04  0:05     ` malc
  2011-01-04  0:48     ` [Qemu-devel] [PATCH] noaudio: correctly account acquired samples Michael Walle
  1 sibling, 0 replies; 6+ messages in thread
From: malc @ 2011-01-04  0:05 UTC (permalink / raw)
  To: Michael Walle; +Cc: qemu-devel

On Mon, 3 Jan 2011, Michael Walle wrote:

> On Mon, 3 Jan 2011, 23:46:34 malc wrote:
> > On Mon, 3 Jan 2011, Michael Walle wrote:
> > > 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.
> 

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

-- 
mailto:av1474@comtv.ru

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Qemu-devel] [PATCH] noaudio: correctly account acquired samples
  2011-01-03 22:59   ` Michael Walle
  2011-01-04  0:05     ` malc
@ 2011-01-04  0:48     ` Michael Walle
  2011-01-04  0:54       ` malc
  1 sibling, 1 reply; 6+ messages in thread
From: Michael Walle @ 2011-01-04  0:48 UTC (permalink / raw)
  To: qemu-devel; +Cc: 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.

Signed-off-by: Michael Walle <michael@walle.cc>
---
 audio/noaudio.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

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;
 }
-- 
1.7.2.3

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCH] noaudio: correctly account acquired samples
  2011-01-04  0:48     ` [Qemu-devel] [PATCH] noaudio: correctly account acquired samples Michael Walle
@ 2011-01-04  0:54       ` malc
  0 siblings, 0 replies; 6+ messages in thread
From: malc @ 2011-01-04  0:54 UTC (permalink / raw)
  To: Michael Walle; +Cc: qemu-devel

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.

-- 
mailto:av1474@comtv.ru

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-01-04  0:54 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-03 22:40 [Qemu-devel] [PATCH] noaudio: use audio_pcm_sw_read() in no_read() Michael Walle
2011-01-03 22:46 ` malc
2011-01-03 22:59   ` Michael Walle
2011-01-04  0:05     ` malc
2011-01-04  0:48     ` [Qemu-devel] [PATCH] noaudio: correctly account acquired samples Michael Walle
2011-01-04  0:54       ` malc

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).