continue;
/* Hmm, nothing to do. Let's sleep */
- if (pa_rtpoll_run(u->rtpoll) < 0) {
+ if (pa_rtpoll_run(u->rtpoll, 1) < 0) {
pa_log("poll() failed: %s", pa_cstrerror(errno));
goto fail;
}
continue;
/* Hmm, nothing to do. Let's sleep */
- if (pa_rtpoll_run(u->rtpoll) < 0) {
+ if (pa_rtpoll_run(u->rtpoll, 1) < 0) {
pa_log("poll() failed: %s", pa_cstrerror(errno));
goto fail;
}
continue;
/* Hmm, nothing to do. Let's sleep */
- if (pa_rtpoll_run(u->rtpoll) < 0) {
+ if (pa_rtpoll_run(u->rtpoll, 1) < 0) {
pa_log("poll() failed: %s", pa_cstrerror(errno));
goto fail;
}
continue;
/* Hmm, nothing to do. Let's sleep */
- if (pa_rtpoll_run(u->rtpoll) < 0) {
+ if (pa_rtpoll_run(u->rtpoll, 1) < 0) {
pa_log("poll() failed: %s", pa_cstrerror(errno));
goto fail;
}
}
/* Hmm, nothing to do. Let's sleep */
- if (pa_rtpoll_run(u->rtpoll) < 0) {
+ if (pa_rtpoll_run(u->rtpoll, 1) < 0) {
pa_log("poll() failed: %s", pa_cstrerror(errno));
goto fail;
}
/* Hmm, nothing to do. Let's sleep */
pollfd->events = u->sink->thread_info.state == PA_SINK_RUNNING ? POLLOUT : 0;
- if (pa_rtpoll_run(u->rtpoll) < 0) {
+ if (pa_rtpoll_run(u->rtpoll, 1) < 0) {
pa_log("poll() failed: %s", pa_cstrerror(errno));
goto fail;
}
/* Hmm, nothing to do. Let's sleep */
pollfd->events = u->source->thread_info.state == PA_SOURCE_RUNNING ? POLLIN : 0;
- if (pa_rtpoll_run(u->rtpoll) < 0) {
+ if (pa_rtpoll_run(u->rtpoll, 1) < 0) {
pa_log("poll() failed: %s", pa_cstrerror(errno));
goto fail;
}
pa_xfree(p);
}
-int pa_rtpoll_run(pa_rtpoll *p) {
+int pa_rtpoll_run(pa_rtpoll *p, int wait) {
pa_rtpoll_item *i;
int r = 0;
int no_events = 0;
rtpoll_rebuild(p);
/* Calculate timeout */
- if (p->timer_enabled) {
+ if (!wait) {
+ timeout.tv_sec = 0;
+ timeout.tv_nsec = 0;
+ } else if (p->timer_enabled) {
struct timespec now;
pa_rtclock_get(&now);
void pa_rtpoll_install(pa_rtpoll *p);
-int pa_rtpoll_run(pa_rtpoll *f);
+/* Sleep on the rtpoll until the time event, or any of the fd events
+ * is triggered. If "wait" is 0 we don't sleep but only update the
+ * struct pollfd. */
+int pa_rtpoll_run(pa_rtpoll *f, int wait);
void pa_rtpoll_set_timer_absolute(pa_rtpoll *p, const struct timespec *ts);
void pa_rtpoll_set_timer_periodic(pa_rtpoll *p, pa_usec_t usec);
pa_rtpoll_install(p);
pa_rtpoll_set_timer_periodic(p, 10000000); /* 10 s */
- pa_rtpoll_run(p);
+ pa_rtpoll_run(p, 1);
pa_rtpoll_item_free(i);
pollfd->fd = 0;
pollfd->events = POLLIN;
- pa_rtpoll_run(p);
+ pa_rtpoll_run(p, 1);
pa_rtpoll_item_free(i);