summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexandre Ratchov <ratchov@cvs.openbsd.org>2010-05-02 10:40:49 +0000
committerAlexandre Ratchov <ratchov@cvs.openbsd.org>2010-05-02 10:40:49 +0000
commit483ca675d693d23badf6f21560d80457643b567f (patch)
tree4205ff7c5d7988fe967f60ec9d53e1d7007234f1
parente74d0a51743999e0b97f0f793d8372d65ddb8d30 (diff)
in the resampling code, handle the case ``diff == 0'', to avoid producing
the first sample of the next block in advance.
-rw-r--r--usr.bin/aucat/aproc.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/usr.bin/aucat/aproc.c b/usr.bin/aucat/aproc.c
index 7fa0c61c6a1..c626ab7aaf0 100644
--- a/usr.bin/aucat/aproc.c
+++ b/usr.bin/aucat/aproc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: aproc.c,v 1.55 2010/04/24 13:32:21 ratchov Exp $ */
+/* $OpenBSD: aproc.c,v 1.56 2010/05/02 10:40:48 ratchov Exp $ */
/*
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
*
@@ -1524,7 +1524,7 @@ resamp_bcopy(struct aproc *p, struct abuf *ibuf, struct abuf *obuf)
}
diff += oblksz;
ifr--;
- } else {
+ } else if (diff > 0) {
if (ofr == 0)
break;
ctx = ctxbuf;
@@ -1536,6 +1536,24 @@ resamp_bcopy(struct aproc *p, struct abuf *ibuf, struct abuf *obuf)
}
diff -= iblksz;
ofr--;
+ } else {
+ if (ifr == 0 || ofr == 0)
+ break;
+ ctx = ctxbuf + ctx_start;
+ for (c = onch; c > 0; c--) {
+ *odata++ = *ctx;
+ ctx += RESAMP_NCTX;
+ }
+ ctx_start ^= 1;
+ ctx = ctxbuf + ctx_start;
+ for (c = inch; c > 0; c--) {
+ *ctx = *idata++;
+ ctx += RESAMP_NCTX;
+ }
+ diff -= iblksz;
+ diff += oblksz;
+ ifr--;
+ ofr--;
}
}
p->u.resamp.diff = diff;