use the hold flag for midi ports as well

This commit is contained in:
Alexandre Ratchov 2012-11-30 22:02:48 +01:00
parent 49190bbba1
commit 0057424c2b
3 changed files with 10 additions and 6 deletions

View File

@ -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

View File

@ -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 *);

View File

@ -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;