version 1.2, 2012/11/30 20:30:24 |
version 1.3, 2012/11/30 20:48:00 |
|
|
|
|
if (log_level >= 3) { |
if (log_level >= 3) { |
port_log(p); |
port_log(p); |
log_puts(": exit\n"); |
log_puts(": port exit\n"); |
|
panic(); |
} |
} |
#endif |
#endif |
} |
} |
|
|
xfree(c); |
xfree(c); |
} |
} |
|
|
|
int |
|
port_ref(struct port *c) |
|
{ |
|
#ifdef DEBUG |
|
if (log_level >= 3) { |
|
port_log(c); |
|
log_puts(": port requested\n"); |
|
} |
|
#endif |
|
if (c->state == PORT_CFG && !port_open(c)) |
|
return 0; |
|
return 1; |
|
} |
|
|
|
void |
|
port_unref(struct port *c) |
|
{ |
|
int i, rxmask; |
|
|
|
#ifdef DEBUG |
|
if (log_level >= 3) { |
|
port_log(c); |
|
log_puts(": port released\n"); |
|
} |
|
#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) |
|
port_close(c); |
|
} |
|
|
struct port * |
struct port * |
port_bynum(int num) |
port_bynum(int num) |
{ |
{ |
|
|
int |
int |
port_close(struct port *c) |
port_close(struct port *c) |
{ |
{ |
|
int i; |
|
struct midi *ep; |
#ifdef DEBUG |
#ifdef DEBUG |
if (c->state == PORT_CFG) { |
if (c->state == PORT_CFG) { |
port_log(c); |
port_log(c); |
log_puts(": can't close port (not opened)\n"); |
log_puts(": can't close port (not opened)\n"); |
|
panic(); |
} |
} |
#endif |
#endif |
port_mio_close(c); |
|
c->state = PORT_CFG; |
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); |
|
} |
return 1; |
return 1; |
} |
} |
|
|