mirror of https://github.com/ericonr/sndio.git
Don't send MIDI flow control messages too often.
This commit is contained in:
parent
2c97522b5a
commit
c75f08ec81
|
@ -239,6 +239,16 @@ midi_tickets(struct midi *iep)
|
||||||
int i, tickets, avail, maxavail;
|
int i, tickets, avail, maxavail;
|
||||||
struct midi *oep;
|
struct midi *oep;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* don't request iep->ops->fill() too often as it generates
|
||||||
|
* useless network traffic: wait until we reach half of the
|
||||||
|
* max tickets count. As in the worst case (see comment below)
|
||||||
|
* one ticket may consume two bytes, the max ticket count is
|
||||||
|
* BUFSZ / 2 and halt of it is simply BUFSZ / 4.
|
||||||
|
*/
|
||||||
|
if (iep->tickets >= MIDI_BUFSZ / 4)
|
||||||
|
return;
|
||||||
|
|
||||||
maxavail = MIDI_BUFSZ;
|
maxavail = MIDI_BUFSZ;
|
||||||
for (i = 0; i < MIDI_NEP ; i++) {
|
for (i = 0; i < MIDI_NEP ; i++) {
|
||||||
if ((iep->txmask & (1 << i)) == 0)
|
if ((iep->txmask & (1 << i)) == 0)
|
||||||
|
|
Loading…
Reference in New Issue