summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorratchov <ratchov@openbsd.org>2016-05-27 16:02:54 +0000
committerratchov <ratchov@openbsd.org>2016-05-27 16:02:54 +0000
commite839ed6e01efa80b4f9f2d3f9b2577be53576299 (patch)
treec44dae9cecb31f7abeedd7d75433f1615cd92315
parentSimplify slot_fill() and slot_flush(). No behaviour change (diff)
downloadwireguard-openbsd-e839ed6e01efa80b4f9f2d3f9b2577be53576299.tar.xz
wireguard-openbsd-e839ed6e01efa80b4f9f2d3f9b2577be53576299.zip
Flush rec buffer if there's less than one block space left and refill
play buffer if there's less than one block of data left. This is the correct condition in the general case. No behaviour change, as all input/output is multiple of the block size.
-rw-r--r--usr.bin/aucat/aucat.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/usr.bin/aucat/aucat.c b/usr.bin/aucat/aucat.c
index f315cfeb526..6e025813f7b 100644
--- a/usr.bin/aucat/aucat.c
+++ b/usr.bin/aucat/aucat.c
@@ -975,9 +975,11 @@ slot_list_iodo(void)
for (s = slot_list; s != NULL; s = s->next) {
if (s->pstate != SLOT_RUN)
continue;
- if ((s->mode & SIO_PLAY) && (s->buf.used == 0))
+ if ((s->mode & SIO_PLAY) &&
+ (s->buf.used < s->round * s->bpf))
slot_fill(s);
- if ((s->mode & SIO_REC) && (s->buf.used == s->buf.len))
+ if ((s->mode & SIO_REC) &&
+ (s->buf.len - s->buf.used < s->round * s->bpf))
slot_flush(s);
}
}