diff options
author | Alexandre Ratchov <ratchov@cvs.openbsd.org> | 2019-08-29 07:10:28 +0000 |
---|---|---|
committer | Alexandre Ratchov <ratchov@cvs.openbsd.org> | 2019-08-29 07:10:28 +0000 |
commit | 1422035ba3ab5b3edb52e98abdcb96b5d2050fab (patch) | |
tree | 566417f3e63e6fcf95475820870d89b6875c2df0 /usr.bin | |
parent | 74f1289089a2a4bd2e22be3715587663fbf6808e (diff) |
Move code de disconnect all MIDI clients to its own routine.
This makes the routine reusable, no behavior change.
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/sndiod/dev.c | 3 | ||||
-rw-r--r-- | usr.bin/sndiod/midi.c | 26 |
2 files changed, 19 insertions, 10 deletions
diff --git a/usr.bin/sndiod/dev.c b/usr.bin/sndiod/dev.c index abbd4080c04..c142228b447 100644 --- a/usr.bin/sndiod/dev.c +++ b/usr.bin/sndiod/dev.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dev.c,v 1.55 2019/08/29 07:07:33 ratchov Exp $ */ +/* $OpenBSD: dev.c,v 1.56 2019/08/29 07:10:27 ratchov Exp $ */ /* * Copyright (c) 2008-2012 Alexandre Ratchov <alex@caoua.org> * @@ -58,6 +58,7 @@ struct dev *dev_new(char *, struct aparams *, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int); void dev_adjpar(struct dev *, int, int, int); int dev_open(struct dev *); +void dev_exitall(struct dev *); void dev_close(struct dev *); int dev_ref(struct dev *); void dev_unref(struct dev *); diff --git a/usr.bin/sndiod/midi.c b/usr.bin/sndiod/midi.c index 12a79f1076e..c42c0da4a92 100644 --- a/usr.bin/sndiod/midi.c +++ b/usr.bin/sndiod/midi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: midi.c,v 1.19 2019/05/10 04:45:47 ratchov Exp $ */ +/* $OpenBSD: midi.c,v 1.20 2019/08/29 07:10:27 ratchov Exp $ */ /* * Copyright (c) 2008-2012 Alexandre Ratchov <alex@caoua.org> * @@ -32,6 +32,7 @@ void port_imsg(void *, unsigned char *, int); void port_omsg(void *, unsigned char *, int); void port_fill(void *, int); void port_exit(void *); +void port_exitall(struct port *); struct midiops port_midiops = { port_imsg, @@ -529,11 +530,23 @@ port_open(struct port *c) return 1; } -int -port_close(struct port *c) +void +port_exitall(struct port *c) { int i; struct midi *ep; + + for (i = 0; i < MIDI_NEP; i++) { + ep = midi_ep + i; + if ((ep->txmask & c->midi->self) || + (c->midi->txmask & ep->self)) + ep->ops->exit(ep->arg); + } +} + +int +port_close(struct port *c) +{ #ifdef DEBUG if (c->state == PORT_CFG) { port_log(c); @@ -544,12 +557,7 @@ port_close(struct port *c) c->state = PORT_CFG; port_mio_close(c); - for (i = 0; i < MIDI_NEP; i++) { - ep = midi_ep + i; - if ((ep->txmask & c->midi->self) || - (c->midi->txmask & ep->self)) - ep->ops->exit(ep->arg); - } + port_exitall(c); return 1; } |