diff options
author | 2016-05-27 15:46:41 +0000 | |
---|---|---|
committer | 2016-05-27 15:46:41 +0000 | |
commit | b37c1ca3b68ec6dbd87f1dd4a83f25edb0e833b4 (patch) | |
tree | 866e3db99510fbc02589419e6b9ac8546c996903 | |
parent | Make resamp_do() get the exact number input and output samples and (diff) | |
download | wireguard-openbsd-b37c1ca3b68ec6dbd87f1dd4a83f25edb0e833b4.tar.xz wireguard-openbsd-b37c1ca3b68ec6dbd87f1dd4a83f25edb0e833b4.zip |
Simplify slot_fill() and slot_flush(). No behaviour change
-rw-r--r-- | usr.bin/aucat/aucat.c | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/usr.bin/aucat/aucat.c b/usr.bin/aucat/aucat.c index 6405d8eef29..f315cfeb526 100644 --- a/usr.bin/aucat/aucat.c +++ b/usr.bin/aucat/aucat.c @@ -157,14 +157,13 @@ slot_log(struct slot *s) static void slot_flush(struct slot *s) { - int todo, count, n; + int count, n; unsigned char *data; - todo = s->buf.used; - while (todo > 0) { + for (;;) { data = abuf_rgetblk(&s->buf, &count); - if (count > todo) - count = todo; + if (count == 0) + break; n = afile_write(&s->afile, data, count); if (n == 0) { slot_log(s); @@ -173,21 +172,19 @@ slot_flush(struct slot *s) return; } abuf_rdiscard(&s->buf, n); - todo -= n; } } static void slot_fill(struct slot *s) { - int todo, count, n; + int count, n; unsigned char *data; - todo = s->buf.len; - while (todo > 0) { + for (;;) { data = abuf_wgetblk(&s->buf, &count); - if (count > todo) - count = todo; + if (count == 0) + break; n = afile_read(&s->afile, data, count); if (n == 0) { #ifdef DEBUG @@ -200,7 +197,6 @@ slot_fill(struct slot *s) break; } abuf_wcommit(&s->buf, n); - todo -= n; } } |