summaryrefslogtreecommitdiff
path: root/usr.bin/sndiod/dev.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/sndiod/dev.c')
-rw-r--r--usr.bin/sndiod/dev.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/usr.bin/sndiod/dev.c b/usr.bin/sndiod/dev.c
index e3ce842711d..06412ae6ade 100644
--- a/usr.bin/sndiod/dev.c
+++ b/usr.bin/sndiod/dev.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dev.c,v 1.81 2021/01/28 11:10:00 ratchov Exp $ */
+/* $OpenBSD: dev.c,v 1.82 2021/01/28 11:15:31 ratchov Exp $ */
/*
* Copyright (c) 2008-2012 Alexandre Ratchov <alex@caoua.org>
*
@@ -1972,9 +1972,8 @@ slot_del(struct slot *s)
case SLOT_START:
case SLOT_READY:
case SLOT_RUN:
- slot_stop(s);
- /* PASSTHROUGH */
case SLOT_STOP:
+ slot_stop(s, 0);
break;
}
dev_unref(s->dev);
@@ -2195,7 +2194,7 @@ slot_detach(struct slot *s)
* stop & detach if no data to drain.
*/
void
-slot_stop(struct slot *s)
+slot_stop(struct slot *s, int drain)
{
#ifdef DEBUG
if (log_level >= 3) {
@@ -2214,7 +2213,7 @@ slot_stop(struct slot *s)
}
if (s->pstate == SLOT_RUN) {
- if (s->mode & MODE_PLAY) {
+ if ((s->mode & MODE_PLAY) && drain) {
/*
* Don't detach, dev_cycle() will do it for us
* when the buffer is drained.
@@ -2223,6 +2222,8 @@ slot_stop(struct slot *s)
return;
}
slot_detach(s);
+ } else if (s->pstate == SLOT_STOP) {
+ slot_detach(s);
} else {
#ifdef DEBUG
if (log_level >= 3) {