diff options
author | Alexandre Ratchov <ratchov@cvs.openbsd.org> | 2021-01-28 11:06:59 +0000 |
---|---|---|
committer | Alexandre Ratchov <ratchov@cvs.openbsd.org> | 2021-01-28 11:06:59 +0000 |
commit | 3c6cbe5eeb97aee44076aa8ac3cae1d7b062a7b3 (patch) | |
tree | 543e4bd740b785db7273f6e790f70e5fa4d1cdf2 /usr.bin/sndiod/dev.c | |
parent | 8b1835512c362d30272634eb002e0e7b9b6dd1c5 (diff) |
Use everywhere the same pattern to handle fractional clock ticks
No behavior change; this change is only to make the maths easier to
proofread
Diffstat (limited to 'usr.bin/sndiod/dev.c')
-rw-r--r-- | usr.bin/sndiod/dev.c | 12 |
1 files changed, 9 insertions, 3 deletions
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 <alex@caoua.org> * @@ -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); } |