On 04/05/2012 10:22 AM, Feng Wei wrote:
When set latency is less than period time, we will assgin working
buffer less than a period size, which will cause unnecessary xrun
and wrong message indicating alsa driver bug.

NAK, I don't think this is correct.

This is tricky stuff though, so don't take my word for it! ;-)

On what machine was this solving a problem for you?

Have you verified it leads to better behaviour (or at least not worse) on both tsched and non-tsched systems?

I e, try a VOIP call with ~20 ms of latency, on a desktop machine that has 2 x 1s periods, running in tsched mode. I'm guessing the latency will be unacceptable with this patch applied.


Signed-off-by: Feng Wei<[email protected]>
---
  src/modules/alsa/alsa-sink.c   |    6 +++---
  src/modules/alsa/alsa-source.c |    6 +++---
  2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/modules/alsa/alsa-sink.c b/src/modules/alsa/alsa-sink.c
index 5a4b606..a53fb6f 100644
--- a/src/modules/alsa/alsa-sink.c
+++ b/src/modules/alsa/alsa-sink.c
@@ -953,10 +953,10 @@ static int update_sw_params(struct userdata *u) {

              b = pa_usec_to_bytes(latency,&u->sink->sample_spec);

-            /* We need at least one sample in our buffer */
+            /* We need at least one period and one sample in our buffer to 
avoid underflow */

-            if (PA_UNLIKELY(b<  u->frame_size))
-                b = u->frame_size;
+            if (PA_UNLIKELY(b<  u->frame_size + u->fragment_size))
+                b = u->frame_size + u->fragment_size;

              u->hwbuf_unused = PA_LIKELY(b<  u->hwbuf_size) ? (u->hwbuf_size - 
b) : 0;
          }
diff --git a/src/modules/alsa/alsa-source.c b/src/modules/alsa/alsa-source.c
index 27fd3b9..8c41ca6 100644
--- a/src/modules/alsa/alsa-source.c
+++ b/src/modules/alsa/alsa-source.c
@@ -876,10 +876,10 @@ static int update_sw_params(struct userdata *u) {

              b = pa_usec_to_bytes(latency,&u->source->sample_spec);

-            /* We need at least one sample in our buffer */
+            /* We need at least one period and one sample in our buffer to 
avoid overflow */

-            if (PA_UNLIKELY(b<  u->frame_size))
-                b = u->frame_size;
+            if (PA_UNLIKELY(b<  u->frame_size + u->fragment_size))
+                b = u->frame_size + u->fragment_size;

              u->hwbuf_unused = PA_LIKELY(b<  u->hwbuf_size) ? (u->hwbuf_size - 
b) : 0;
          }



--
David Henningsson, Canonical Ltd.
http://launchpad.net/~diwic
_______________________________________________
pulseaudio-discuss mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss

Reply via email to