summaryrefslogtreecommitdiff
path: root/usr.bin/sndiod
diff options
context:
space:
mode:
authorAlexandre Ratchov <ratchov@cvs.openbsd.org>2018-06-26 07:11:00 +0000
committerAlexandre Ratchov <ratchov@cvs.openbsd.org>2018-06-26 07:11:00 +0000
commit33586a31f2df2bc4cf710a16c19e55075b133471 (patch)
tree0374449eb91f2c2359b3f3360d6ad4af172185ef /usr.bin/sndiod
parent139f84d09b15ee6610bdbc8b36895556906c13de (diff)
Factor common code of slot_stop().
Diffstat (limited to 'usr.bin/sndiod')
-rw-r--r--usr.bin/sndiod/dev.c38
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