summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTanu Kaskinen <tanu.kaskinen@digia.com>2012-04-25 10:51:38 +0300
committerTanu Kaskinen <tanuk@iki.fi>2012-04-27 11:37:26 +0300
commitaca1c4001def39641e8662848bb70f8b54b394da (patch)
tree3944ac1653a07f6f9e294200876f86da4e555d0c
parentaf78613b7042d313c4bbc0df680db5fcd64f0f6c (diff)
echo-cancel: Fix memblockq length check.
In addition to changing "plen > u->blocksize" to "plen >= u->blocksize", I also removed one of the duplicated ifs.
-rw-r--r--src/modules/echo-cancel/module-echo-cancel.c86
1 files changed, 42 insertions, 44 deletions
diff --git a/src/modules/echo-cancel/module-echo-cancel.c b/src/modules/echo-cancel/module-echo-cancel.c
index 5ca5d1e2..297f19ee 100644
--- a/src/modules/echo-cancel/module-echo-cancel.c
+++ b/src/modules/echo-cancel/module-echo-cancel.c
@@ -806,51 +806,49 @@ static void do_push(struct userdata *u) {
/* take fixed block from recorded samples */
pa_memblockq_peek_fixed_size(u->source_memblockq, u->blocksize, &rchunk);
- if (plen > u->blocksize) {
- if (plen > u->blocksize) {
- /* take fixed block from played samples */
- pa_memblockq_peek_fixed_size(u->sink_memblockq, u->blocksize, &pchunk);
-
- rdata = pa_memblock_acquire(rchunk.memblock);
- rdata += rchunk.index;
- pdata = pa_memblock_acquire(pchunk.memblock);
- pdata += pchunk.index;
-
- cchunk.index = 0;
- cchunk.length = u->blocksize;
- cchunk.memblock = pa_memblock_new(u->source->core->mempool, cchunk.length);
- cdata = pa_memblock_acquire(cchunk.memblock);
-
- if (u->save_aec) {
- if (u->captured_file)
- unused = fwrite(rdata, 1, u->blocksize, u->captured_file);
- if (u->played_file)
- unused = fwrite(pdata, 1, u->blocksize, u->played_file);
- }
-
- /* perform echo cancellation */
- u->ec->run(u->ec, rdata, pdata, cdata);
-
- if (u->save_aec) {
- if (u->canceled_file)
- unused = fwrite(cdata, 1, u->blocksize, u->canceled_file);
- }
-
- pa_memblock_release(cchunk.memblock);
- pa_memblock_release(pchunk.memblock);
- pa_memblock_release(rchunk.memblock);
-
- /* drop consumed sink samples */
- pa_memblockq_drop(u->sink_memblockq, u->blocksize);
- pa_memblock_unref(pchunk.memblock);
-
- pa_memblock_unref(rchunk.memblock);
- /* the filtered samples now become the samples from our
- * source */
- rchunk = cchunk;
-
- plen -= u->blocksize;
+ if (plen >= u->blocksize) {
+ /* take fixed block from played samples */
+ pa_memblockq_peek_fixed_size(u->sink_memblockq, u->blocksize, &pchunk);
+
+ rdata = pa_memblock_acquire(rchunk.memblock);
+ rdata += rchunk.index;
+ pdata = pa_memblock_acquire(pchunk.memblock);
+ pdata += pchunk.index;
+
+ cchunk.index = 0;
+ cchunk.length = u->blocksize;
+ cchunk.memblock = pa_memblock_new(u->source->core->mempool, cchunk.length);
+ cdata = pa_memblock_acquire(cchunk.memblock);
+
+ if (u->save_aec) {
+ if (u->captured_file)
+ unused = fwrite(rdata, 1, u->blocksize, u->captured_file);
+ if (u->played_file)
+ unused = fwrite(pdata, 1, u->blocksize, u->played_file);
}
+
+ /* perform echo cancellation */
+ u->ec->run(u->ec, rdata, pdata, cdata);
+
+ if (u->save_aec) {
+ if (u->canceled_file)
+ unused = fwrite(cdata, 1, u->blocksize, u->canceled_file);
+ }
+
+ pa_memblock_release(cchunk.memblock);
+ pa_memblock_release(pchunk.memblock);
+ pa_memblock_release(rchunk.memblock);
+
+ /* drop consumed sink samples */
+ pa_memblockq_drop(u->sink_memblockq, u->blocksize);
+ pa_memblock_unref(pchunk.memblock);
+
+ pa_memblock_unref(rchunk.memblock);
+ /* the filtered samples now become the samples from our
+ * source */
+ rchunk = cchunk;
+
+ plen -= u->blocksize;
}
/* forward the (echo-canceled) data to the virtual source */