diff options
author | Alexandre Ratchov <ratchov@cvs.openbsd.org> | 2012-11-30 21:04:36 +0000 |
---|---|---|
committer | Alexandre Ratchov <ratchov@cvs.openbsd.org> | 2012-11-30 21:04:36 +0000 |
commit | d717e7701c1f9df60b1f10b245ba9c0c27ba8051 (patch) | |
tree | 22568e7931966a522582f92d604da14c11093d08 /usr.bin/sndiod | |
parent | c06063a893a41e0a01a2ddd5e34be323daa2b44a (diff) |
use the hold flag for midi ports as well
Diffstat (limited to 'usr.bin/sndiod')
-rw-r--r-- | usr.bin/sndiod/midi.c | 11 | ||||
-rw-r--r-- | usr.bin/sndiod/midi.h | 7 | ||||
-rw-r--r-- | usr.bin/sndiod/sndiod.c | 4 |
3 files changed, 13 insertions, 9 deletions
diff --git a/usr.bin/sndiod/midi.c b/usr.bin/sndiod/midi.c index 02e2c659904..a30402abec3 100644 --- a/usr.bin/sndiod/midi.c +++ b/usr.bin/sndiod/midi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: midi.c,v 1.3 2012/11/30 20:48:00 ratchov Exp $ */ +/* $OpenBSD: midi.c,v 1.4 2012/11/30 21:04:35 ratchov Exp $ */ /* * Copyright (c) 2008-2012 Alexandre Ratchov <alex@caoua.org> * @@ -452,13 +452,14 @@ port_exit(void *arg) * create a new midi port */ struct port * -port_new(char *path, unsigned int mode) +port_new(char *path, unsigned int mode, int hold) { struct port *c; c = xmalloc(sizeof(struct port)); c->path = path; c->state = PORT_CFG; + c->hold = hold; c->midi = midi_new(&port_midiops, c, mode); midi_portnum++; c->next = port_list; @@ -516,7 +517,7 @@ port_unref(struct port *c) #endif for (rxmask = 0, i = 0; i < MIDI_NEP; i++) rxmask |= midi_ep[i].txmask; - if ((rxmask & c->midi->self) == 0 && c->state == PORT_INIT) + if ((rxmask & c->midi->self) == 0 && c->state == PORT_INIT && !c->hold) port_close(c); } @@ -573,7 +574,9 @@ port_close(struct port *c) int port_init(struct port *c) { - return port_open(c); + if (c->hold) + return port_open(c); + return 1; } void diff --git a/usr.bin/sndiod/midi.h b/usr.bin/sndiod/midi.h index b3a76076153..35b678f8065 100644 --- a/usr.bin/sndiod/midi.h +++ b/usr.bin/sndiod/midi.h @@ -1,4 +1,4 @@ -/* $OpenBSD: midi.h,v 1.3 2012/11/30 20:48:00 ratchov Exp $ */ +/* $OpenBSD: midi.h,v 1.4 2012/11/30 21:04:35 ratchov Exp $ */ /* * Copyright (c) 2008-2012 Alexandre Ratchov <alex@caoua.org> * @@ -87,7 +87,8 @@ struct port { #define PORT_INIT 1 #define PORT_DRAIN 2 unsigned int state; - char *path; + char *path; /* hold the port open ? */ + int hold; struct midi *midi; }; @@ -109,7 +110,7 @@ void midi_fill(struct midi *); void midi_tag(struct midi *, unsigned int); void midi_link(struct midi *, struct midi *); -struct port *port_new(char *, unsigned int); +struct port *port_new(char *, unsigned int, int); struct port *port_bynum(int); void port_del(struct port *); int port_ref(struct port *); diff --git a/usr.bin/sndiod/sndiod.c b/usr.bin/sndiod/sndiod.c index 363aa267ed8..059446991c3 100644 --- a/usr.bin/sndiod/sndiod.c +++ b/usr.bin/sndiod/sndiod.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sndiod.c,v 1.2 2012/11/23 07:25:07 ratchov Exp $ */ +/* $OpenBSD: sndiod.c,v 1.3 2012/11/30 21:04:35 ratchov Exp $ */ /* * Copyright (c) 2008-2012 Alexandre Ratchov <alex@caoua.org> * @@ -389,7 +389,7 @@ main(int argc, char **argv) mode, vol, mmc, dup); break; case 'q': - p = port_new(optarg, MODE_MIDIMASK); + p = port_new(optarg, MODE_MIDIMASK, hold); if (!p) errx(1, "%s: can't open port", optarg); break; |