diff options
author | Alexandre Ratchov <ratchov@cvs.openbsd.org> | 2010-04-24 13:32:22 +0000 |
---|---|---|
committer | Alexandre Ratchov <ratchov@cvs.openbsd.org> | 2010-04-24 13:32:22 +0000 |
commit | 297a811ebab990c57575a09504e34bc8c081f091 (patch) | |
tree | 33457c11674fe3c35bf3928753a21e16a7b5aa2e | |
parent | 507cd65c6c291606b1978ef3a4280933dc1c5e76 (diff) |
don't increment mixer's ``idle'' counter before truncating the
amount of samples to commit to ``maxwrite''. Overwise uncommitted
samples are accounted as idle, in turn causing the device to be
stopped too early, possibly truncating few blocks at the end of
streams being drained.
subtle bug spotted and analysed by Thomas Pfaff, thanks
-rw-r--r-- | usr.bin/aucat/aproc.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/usr.bin/aucat/aproc.c b/usr.bin/aucat/aproc.c index 74b9be95dc3..7fa0c61c6a1 100644 --- a/usr.bin/aucat/aproc.c +++ b/usr.bin/aucat/aproc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: aproc.c,v 1.54 2010/04/24 06:18:23 ratchov Exp $ */ +/* $OpenBSD: aproc.c,v 1.55 2010/04/24 13:32:21 ratchov Exp $ */ /* * Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org> * @@ -854,6 +854,7 @@ mix_out(struct aproc *p, struct abuf *obuf) maxwrite = p->u.mix.maxlat - p->u.mix.lat; mix_bzero(obuf); scount = 0; + /* XXX: can obuf->len be larger than obuf->w.mix.todo ? */ odone = obuf->len; for (i = LIST_FIRST(&p->ins); i != NULL; i = inext) { inext = LIST_NEXT(i, ient); @@ -878,7 +879,6 @@ mix_out(struct aproc *p, struct abuf *obuf) if (!(p->flags & APROC_DROP)) return 0; odone = obuf->w.mix.todo; - p->u.mix.idle += odone; } if (maxwrite > 0) { if (odone > maxwrite) @@ -893,6 +893,8 @@ mix_out(struct aproc *p, struct abuf *obuf) if (APROC_OK(p->u.mix.mon)) mon_snoop(p->u.mix.mon, obuf, obuf->used - odone, odone); } + if (LIST_EMPTY(&p->ins)) + p->u.mix.idle += odone; if (scount == 0) return 0; return 1; |