echo-cancel: Skip processing till there's enough data
authorArun Raghavan <arun.raghavan@collabora.co.uk>
Wed, 5 Oct 2011 06:59:10 +0000 (12:29 +0530)
committerArun Raghavan <arun.raghavan@collabora.co.uk>
Mon, 10 Oct 2011 07:56:27 +0000 (13:26 +0530)
This makes sure that we only perform any processing (resync or actual
cancellation) after the source provides enough data to actuall run the
canceller.

src/modules/echo-cancel/module-echo-cancel.c

index 8d77a3b..77c8ff8 100644 (file)
@@ -665,15 +665,19 @@ static void source_output_push_cb(pa_source_output *o, const pa_memchunk *chunk)
     while (pa_asyncmsgq_process_one(u->asyncmsgq) > 0)
         ;
 
-    if (pa_atomic_cmpxchg (&u->request_resync, 1, 0)) {
-        do_resync(u);
-    }
-
     pa_memblockq_push_align(u->source_memblockq, chunk);
 
     rlen = pa_memblockq_get_length(u->source_memblockq);
     plen = pa_memblockq_get_length(u->sink_memblockq);
 
+    /* Let's not do anything else till we have enough data to process */
+    if (rlen < u->blocksize)
+        return;
+
+    if (pa_atomic_cmpxchg (&u->request_resync, 1, 0)) {
+        do_resync(u);
+    }
+
     while (rlen >= u->blocksize) {
         pa_memchunk rchunk, pchunk;