mirror of https://github.com/ericonr/sndio.git
drain midi port output buffer before closing it ensuring the last
few bytes are not lost
This commit is contained in:
parent
0057424c2b
commit
7a76f322eb
|
@ -519,7 +519,7 @@ port_unref(struct port *c)
|
||||||
for (rxmask = 0, i = 0; i < MIDI_NEP; i++)
|
for (rxmask = 0, i = 0; i < MIDI_NEP; i++)
|
||||||
rxmask |= midi_ep[i].txmask;
|
rxmask |= midi_ep[i].txmask;
|
||||||
if ((rxmask & c->midi->self) == 0 && c->state == PORT_INIT && !c->hold)
|
if ((rxmask & c->midi->self) == 0 && c->state == PORT_INIT && !c->hold)
|
||||||
port_close(c);
|
port_drain(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct port *
|
struct port *
|
||||||
|
@ -572,6 +572,24 @@ port_close(struct port *c)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
port_drain(struct port *c)
|
||||||
|
{
|
||||||
|
struct midi *ep = c->midi;
|
||||||
|
|
||||||
|
if (!(ep->mode & MODE_MIDIOUT) || ep->obuf.used == 0)
|
||||||
|
port_close(c);
|
||||||
|
else {
|
||||||
|
c->state = PORT_DRAIN;
|
||||||
|
#ifdef DEBUG
|
||||||
|
if (log_level >= 3) {
|
||||||
|
port_log(c);
|
||||||
|
log_puts(": draining\n");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
port_init(struct port *c)
|
port_init(struct port *c)
|
||||||
{
|
{
|
||||||
|
@ -583,7 +601,6 @@ port_init(struct port *c)
|
||||||
void
|
void
|
||||||
port_done(struct port *c)
|
port_done(struct port *c)
|
||||||
{
|
{
|
||||||
/* XXX: drain? */
|
if (c->state == PORT_INIT)
|
||||||
if (c->state != PORT_CFG)
|
port_drain(c);
|
||||||
port_close(c);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,6 +117,7 @@ int port_ref(struct port *);
|
||||||
void port_unref(struct port *);
|
void port_unref(struct port *);
|
||||||
int port_init(struct port *);
|
int port_init(struct port *);
|
||||||
void port_done(struct port *);
|
void port_done(struct port *);
|
||||||
|
void port_drain(struct port *);
|
||||||
int port_close(struct port *);
|
int port_close(struct port *);
|
||||||
|
|
||||||
#endif /* !defined(MIDI_H) */
|
#endif /* !defined(MIDI_H) */
|
||||||
|
|
|
@ -118,6 +118,8 @@ port_mio_out(void *arg)
|
||||||
if (n < count)
|
if (n < count)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (p->state == PORT_DRAIN && ep->obuf.used == 0)
|
||||||
|
port_close(p);
|
||||||
midi_fill(ep);
|
midi_fill(ep);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue