summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorratchov <ratchov@openbsd.org>2019-08-29 07:07:33 +0000
committerratchov <ratchov@openbsd.org>2019-08-29 07:07:33 +0000
commita88e8d4be0449c73f26b4909f973123549b1370f (patch)
treef6a59921296c472314b5fbfe358984fc8da6724b
parentUniformize device-specific debug printfs (diff)
downloadwireguard-openbsd-a88e8d4be0449c73f26b4909f973123549b1370f.tar.xz
wireguard-openbsd-a88e8d4be0449c73f26b4909f973123549b1370f.zip
Move code de disconnect all audio clients to its own routine.
This makes the routine reusable, no behavior change.
-rw-r--r--usr.bin/sndiod/dev.c29
1 files changed, 19 insertions, 10 deletions
diff --git a/usr.bin/sndiod/dev.c b/usr.bin/sndiod/dev.c
index 029fefded5d..abbd4080c04 100644
--- a/usr.bin/sndiod/dev.c
+++ b/usr.bin/sndiod/dev.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dev.c,v 1.54 2019/07/12 06:30:55 ratchov Exp $ */
+/* $OpenBSD: dev.c,v 1.55 2019/08/29 07:07:33 ratchov Exp $ */
/*
* Copyright (c) 2008-2012 Alexandre Ratchov <alex@caoua.org>
*
@@ -1108,15 +1108,29 @@ dev_open(struct dev *d)
}
/*
- * force the device to go in DEV_CFG state, the caller is supposed to
- * ensure buffers are drained
+ * Force all slots to exit
*/
void
-dev_close(struct dev *d)
+dev_exitall(struct dev *d)
{
int i;
struct slot *s;
+ for (s = d->slot, i = DEV_NSLOT; i > 0; i--, s++) {
+ if (s->ops)
+ s->ops->exit(s->arg);
+ s->ops = NULL;
+ }
+ d->slot_list = NULL;
+}
+
+/*
+ * force the device to go in DEV_CFG state, the caller is supposed to
+ * ensure buffers are drained
+ */
+void
+dev_close(struct dev *d)
+{
#ifdef DEBUG
if (log_level >= 3) {
dev_log(d);
@@ -1124,12 +1138,7 @@ dev_close(struct dev *d)
}
#endif
d->pstate = DEV_CFG;
- for (s = d->slot, i = DEV_NSLOT; i > 0; i--, s++) {
- if (s->ops)
- s->ops->exit(s->arg);
- s->ops = NULL;
- }
- d->slot_list = NULL;
+ dev_exitall(d);
dev_sio_close(d);
if (d->mode & MODE_PLAY) {
if (d->encbuf != NULL)