mirror of https://github.com/ericonr/sndio.git
If there are no descriptors to poll, just sleep until SIGALRM
is posted and then update all timers restart the event loop. Fixes throtteling while midi inputs are drained.
This commit is contained in:
parent
c7037f95a6
commit
0602f18759
22
aucat/file.c
22
aucat/file.c
|
@ -297,7 +297,8 @@ file_poll(void)
|
|||
struct file *f, *fnext;
|
||||
struct aproc *p;
|
||||
struct timespec ts;
|
||||
long delta_nsec;
|
||||
long long delta_nsec;
|
||||
int res;
|
||||
|
||||
if (LIST_EMPTY(&file_list)) {
|
||||
#ifdef DEBUG
|
||||
|
@ -346,20 +347,25 @@ file_poll(void)
|
|||
dbg_puts("\n");
|
||||
}
|
||||
#endif
|
||||
if (nfds > 0) {
|
||||
if (poll(pfds, nfds, -1) < 0) {
|
||||
if (errno == EINTR)
|
||||
return 1;
|
||||
err(1, "file_poll: poll failed");
|
||||
}
|
||||
res = poll(pfds, nfds, -1);
|
||||
if (res < 0 && errno != EINTR)
|
||||
err(1, "poll");
|
||||
clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||
delta_nsec = 1000000000L * (ts.tv_sec - file_ts.tv_sec);
|
||||
delta_nsec = 1000000000LL * (ts.tv_sec - file_ts.tv_sec);
|
||||
delta_nsec += ts.tv_nsec - file_ts.tv_nsec;
|
||||
if (delta_nsec > 0) {
|
||||
file_ts = ts;
|
||||
if (delta_nsec < 1000000000LL)
|
||||
timo_update(delta_nsec / 1000);
|
||||
else {
|
||||
#ifdef DEBUG
|
||||
dbg_puts("ignored huge clock delta\n");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
if (res <= 0)
|
||||
return 1;
|
||||
|
||||
f = LIST_FIRST(&file_list);
|
||||
while (f != NULL) {
|
||||
if (f->pfd == NULL) {
|
||||
|
|
Loading…
Reference in New Issue