diff options
-rw-r--r-- | usr.bin/sndiod/dev.c | 38 |
1 files changed, 21 insertions, 17 deletions
diff --git a/usr.bin/sndiod/dev.c b/usr.bin/sndiod/dev.c index 5244c3a2249..8c77f9fcdb9 100644 --- a/usr.bin/sndiod/dev.c +++ b/usr.bin/sndiod/dev.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dev.c,v 1.33 2018/06/26 07:09:38 ratchov Exp $ */ +/* $OpenBSD: dev.c,v 1.34 2018/06/26 07:10:59 ratchov Exp $ */ /* * Copyright (c) 2008-2012 Alexandre Ratchov <alex@caoua.org> * @@ -1874,31 +1874,35 @@ slot_stop(struct slot *s) s->pstate = SLOT_READY; slot_ready(s); } + + if (s->tstate != MMC_OFF) + s->tstate = MMC_STOP; + if (s->mode & MODE_RECMASK) abuf_done(&s->sub.buf); - if (s->pstate == SLOT_READY) { + + if (s->pstate == SLOT_RUN) { + if (s->mode & MODE_PLAY) { + /* + * Don't detach, dev_cycle() will do it for us + * when the buffer is drained. + */ + s->pstate = SLOT_STOP; + return; + } + slot_detach(s); + } else { #ifdef DEBUG if (log_level >= 3) { slot_log(s); log_puts(": not drained (blocked by mmc)\n"); } #endif - if (s->mode & MODE_PLAY) - abuf_done(&s->mix.buf); - s->ops->eof(s->arg); - s->pstate = SLOT_INIT; - } else { - /* s->pstate == SLOT_RUN */ - if (s->mode & MODE_PLAY) - s->pstate = SLOT_STOP; - else { - slot_detach(s); - s->pstate = SLOT_INIT; - s->ops->eof(s->arg); - } } - if (s->tstate != MMC_OFF) - s->tstate = MMC_STOP; + if (s->mode & MODE_PLAY) + abuf_done(&s->mix.buf); + s->pstate = SLOT_INIT; + s->ops->eof(s->arg); } void |