mirror of https://github.com/ericonr/sndio.git
Merge branch 'master' into mixer
This commit is contained in:
commit
3886e0681d
|
@ -574,7 +574,8 @@ _aucat_open(struct aucat *hdl, const char *str, unsigned int mode)
|
|||
void
|
||||
_aucat_close(struct aucat *hdl, int eof)
|
||||
{
|
||||
char dummy[1];
|
||||
char dummy[sizeof(struct amsg)];
|
||||
ssize_t n;
|
||||
|
||||
if (!eof) {
|
||||
AMSG_INIT(&hdl->wmsg);
|
||||
|
@ -582,8 +583,20 @@ _aucat_close(struct aucat *hdl, int eof)
|
|||
hdl->wtodo = sizeof(struct amsg);
|
||||
if (!_aucat_wmsg(hdl, &eof))
|
||||
goto bad_close;
|
||||
while (read(hdl->fd, dummy, 1) < 0 && errno == EINTR)
|
||||
; /* nothing */
|
||||
|
||||
/*
|
||||
* block until the peer disconnects
|
||||
*/
|
||||
while (1) {
|
||||
n = read(hdl->fd, dummy, sizeof(dummy));
|
||||
if (n < 0) {
|
||||
if (errno == EINTR)
|
||||
continue;
|
||||
break;
|
||||
}
|
||||
if (n == 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
bad_close:
|
||||
while (close(hdl->fd) < 0 && errno == EINTR)
|
||||
|
|
|
@ -239,6 +239,16 @@ midi_tickets(struct midi *iep)
|
|||
int i, tickets, avail, maxavail;
|
||||
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;
|
||||
for (i = 0; i < MIDI_NEP ; i++) {
|
||||
if ((iep->txmask & (1 << i)) == 0)
|
||||
|
|
Loading…
Reference in New Issue