diff options
author | Lennart Poettering <lennart@poettering.net> | 2004-09-01 00:23:51 +0000 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2004-09-01 00:23:51 +0000 |
commit | 34fe8bd893ed9c7531bc4898b934ef9d4cdf3e68 (patch) | |
tree | 816a8543d3521eb43fb49c67af33afc44769bd91 /polyp/mainloop.c | |
parent | 9618aea5df5bf2c5069575f28a935c2039fc55e0 (diff) |
add support for SCHED_FIFO
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@163 fefdeb5f-60dc-0310-8127-8f9354f1896f
Diffstat (limited to 'polyp/mainloop.c')
-rw-r--r-- | polyp/mainloop.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/polyp/mainloop.c b/polyp/mainloop.c index 20d14e51..83f0b1e8 100644 --- a/polyp/mainloop.c +++ b/polyp/mainloop.c @@ -332,6 +332,7 @@ void pa_mainloop_free(struct pa_mainloop* m) { static void scan_dead(struct pa_mainloop *m) { int all = 0; assert(m); + if (m->io_events_scan_dead) pa_idxset_foreach(m->io_events, io_foreach, &all); if (m->time_events_scan_dead) @@ -402,7 +403,7 @@ static void dispatch_defer(struct pa_mainloop *m) { for (e = pa_idxset_first(m->defer_events, &index); e; e = pa_idxset_next(m->defer_events, &index)) { if (e->dead || !e->enabled) continue; - + assert(e->callback); e->callback(&m->api, e, e->userdata); } @@ -413,18 +414,23 @@ static int calc_next_timeout(struct pa_mainloop *m) { struct pa_time_event *e; struct timeval now; int t = -1; + int got_time = 0; if (pa_idxset_isempty(m->time_events)) return -1; - gettimeofday(&now, NULL); - for (e = pa_idxset_first(m->time_events, &index); e; e = pa_idxset_next(m->time_events, &index)) { int tmp; if (e->dead || !e->enabled) continue; + /* Let's save a system call */ + if (!got_time) { + gettimeofday(&now, NULL); + got_time = 1; + } + if (e->timeval.tv_sec < now.tv_sec || (e->timeval.tv_sec == now.tv_sec && e->timeval.tv_usec <= now.tv_usec)) return 0; @@ -448,17 +454,23 @@ static void dispatch_timeout(struct pa_mainloop *m) { uint32_t index; struct pa_time_event *e; struct timeval now; + int got_time = 0; assert(m); if (pa_idxset_isempty(m->time_events)) return; - gettimeofday(&now, NULL); for (e = pa_idxset_first(m->time_events, &index); e; e = pa_idxset_next(m->time_events, &index)) { if (e->dead || !e->enabled) continue; + /* Let's save a system call */ + if (!got_time) { + gettimeofday(&now, NULL); + got_time = 1; + } + if (e->timeval.tv_sec < now.tv_sec || (e->timeval.tv_sec == now.tv_sec && e->timeval.tv_usec <= now.tv_usec)) { assert(e->callback); |