From 0057424c2b28ba20fb74721ec5b3f6f8a9dca0ec Mon Sep 17 00:00:00 2001 From: Alexandre Ratchov Date: Fri, 30 Nov 2012 22:02:48 +0100 Subject: [PATCH] use the hold flag for midi ports as well --- sndiod/midi.c | 9 ++++++--- sndiod/midi.h | 5 +++-- sndiod/sndiod.c | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/sndiod/midi.c b/sndiod/midi.c index 9c1beb6..cb5af2c 100644 --- a/sndiod/midi.c +++ b/sndiod/midi.c @@ -453,13 +453,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; @@ -517,7 +518,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); } @@ -574,7 +575,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/sndiod/midi.h b/sndiod/midi.h index 20d10fe..719f772 100644 --- a/sndiod/midi.h +++ b/sndiod/midi.h @@ -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/sndiod/sndiod.c b/sndiod/sndiod.c index bc0611e..efcf6a8 100644 --- a/sndiod/sndiod.c +++ b/sndiod/sndiod.c @@ -390,7 +390,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;