diff options
author | 2010-01-17 19:17:23 +0000 | |
---|---|---|
committer | 2010-01-17 19:17:23 +0000 | |
commit | fe51ad42b2cf5ae10062096dcc833b2f0e33e31e (patch) | |
tree | 002969f4ecb7007b99ff035fb0690031941ad639 | |
parent | fix quality degradation when resampling (diff) | |
download | wireguard-openbsd-fe51ad42b2cf5ae10062096dcc833b2f0e33e31e.tar.xz wireguard-openbsd-fe51ad42b2cf5ae10062096dcc833b2f0e33e31e.zip |
While resampling, if input samples are available but output
is blocked don't start processing input. Similarly don't
produce output if input is blocked. This is to ensure that
to each output block corresponds exactly one input block.
This is necessary for full-duplex clients using block-based
i/o and very small buffers.
-rw-r--r-- | usr.bin/aucat/aproc.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/usr.bin/aucat/aproc.c b/usr.bin/aucat/aproc.c index d8ad5c1d91b..598cd16c9d6 100644 --- a/usr.bin/aucat/aproc.c +++ b/usr.bin/aucat/aproc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: aproc.c,v 1.47 2010/01/17 16:09:30 ratchov Exp $ */ +/* $OpenBSD: aproc.c,v 1.48 2010/01/17 19:17:23 ratchov Exp $ */ /* * Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org> * @@ -1258,8 +1258,6 @@ resamp_bcopy(struct aproc *p, struct abuf *ibuf, struct abuf *obuf) #endif for (;;) { if (diff < 0) { - if (ifr == 0) - break; ctx_start ^= 1; ctx = ctxbuf + ctx_start; for (c = inch; c > 0; c--) { @@ -1267,10 +1265,9 @@ resamp_bcopy(struct aproc *p, struct abuf *ibuf, struct abuf *obuf) ctx += RESAMP_NCTX; } diff += oblksz; - ifr--; - } else { - if (ofr == 0) + if (--ifr == 0) break; + } else { ctx = ctxbuf; for (c = onch; c > 0; c--) { s1 = ctx[ctx_start]; @@ -1279,7 +1276,8 @@ resamp_bcopy(struct aproc *p, struct abuf *ibuf, struct abuf *obuf) *odata++ = s1 + (s2 - s1) * diff / (int)oblksz; } diff -= iblksz; - ofr--; + if (--ofr == 0) + break; } } p->u.resamp.diff = diff; @@ -1387,7 +1385,7 @@ resamp_new(char *name, unsigned iblksz, unsigned oblksz) p = aproc_new(&resamp_ops, name); p->u.resamp.iblksz = iblksz; p->u.resamp.oblksz = oblksz; - p->u.resamp.diff = (iblksz >= oblksz) ? -oblksz : 0; + p->u.resamp.diff = 0; p->u.resamp.idelta = 0; p->u.resamp.odelta = 0; p->u.resamp.ctx_start = 0; |