From: ratchov Date: Thu, 28 Jan 2021 11:06:58 +0000 (+0000) Subject: Use everywhere the same pattern to handle fractional clock ticks X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=540a9b644530a7facb9f69c2d6e730ae4b776abe;p=openbsd Use everywhere the same pattern to handle fractional clock ticks No behavior change; this change is only to make the maths easier to proofread --- diff --git a/usr.bin/sndiod/dev.c b/usr.bin/sndiod/dev.c index 2f425dac7d7..e416f33f0f8 100644 --- a/usr.bin/sndiod/dev.c +++ b/usr.bin/sndiod/dev.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dev.c,v 1.79 2021/01/28 11:06:07 ratchov Exp $ */ +/* $OpenBSD: dev.c,v 1.80 2021/01/28 11:06:58 ratchov Exp $ */ /* * Copyright (c) 2008-2012 Alexandre Ratchov * @@ -948,9 +948,15 @@ dev_onmove(struct dev *d, int delta) * s->ops->onmove() may remove the slot */ snext = s->next; - pos = (long long)delta * s->round + s->delta_rem; + pos = s->delta_rem + + (long long)s->delta * d->round + + (long long)delta * s->round; + s->delta = pos / (int)d->round; s->delta_rem = pos % d->round; - s->delta += pos / (int)d->round; + if (s->delta_rem < 0) { + s->delta_rem += d->round; + s->delta--; + } if (s->delta >= 0) s->ops->onmove(s->arg); }