[pulseaudio-commits] r2217 - in /branches/glitch-free/src/pulsecore: rtpoll.c rtpoll.h
svnmailer-noreply at 0pointer.de
svnmailer-noreply at 0pointer.de
Fri Apr 4 09:05:16 PDT 2008
Author: lennart
Date: Fri Apr 4 18:05:15 2008
New Revision: 2217
URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=2217&root=pulseaudio&view=rev
Log:
drop support for periodic timers, cleanup code a bit
Modified:
branches/glitch-free/src/pulsecore/rtpoll.c
branches/glitch-free/src/pulsecore/rtpoll.h
Modified: branches/glitch-free/src/pulsecore/rtpoll.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/glitch-free/src/pulsecore/rtpoll.c?rev=2217&root=pulseaudio&r1=2216&r2=2217&view=diff
==============================================================================
--- branches/glitch-free/src/pulsecore/rtpoll.c (original)
+++ branches/glitch-free/src/pulsecore/rtpoll.c Fri Apr 4 18:05:15 2008
@@ -63,7 +63,6 @@
pa_bool_t timer_enabled;
struct timeval next_elapse;
- pa_usec_t period;
pa_bool_t scan_for_dead;
pa_bool_t running, installed, rebuild_needed, quit;
@@ -139,7 +138,6 @@
p->pollfd2 = pa_xnew(struct pollfd, p->n_pollfd_alloc);
p->n_pollfd_used = 0;
- p->period = 0;
memset(&p->next_elapse, 0, sizeof(p->next_elapse));
p->timer_enabled = FALSE;
@@ -368,15 +366,13 @@
if (p->rebuild_needed)
rtpoll_rebuild(p);
+ memset(&timeout, 0, sizeof(timeout));
+
/* Calculate timeout */
- if (!wait || p->quit) {
- timeout.tv_sec = 0;
- timeout.tv_usec = 0;
- } else if (p->timer_enabled) {
+ if (wait && !p->quit && p->timer_enabled) {
struct timeval now;
pa_rtclock_get(&now);
- memset(&timeout, 0, sizeof(timeout));
if (pa_timeval_cmp(&p->next_elapse, &now) > 0)
pa_timeval_add(&timeout, pa_timeval_diff(&p->next_elapse, &now));
}
@@ -391,14 +387,14 @@
struct timespec ts;
ts.tv_sec = timeout.tv_sec;
ts.tv_nsec = timeout.tv_usec * 1000;
- r = ppoll(p->pollfd, p->n_pollfd_used, p->timer_enabled ? &ts : NULL, p->rtsig < 0 ? NULL : &p->sigset_unblocked);
+ r = ppoll(p->pollfd, p->n_pollfd_used, (!wait || p->quit || p->timer_enabled) ? &ts : NULL, p->rtsig < 0 ? NULL : &p->sigset_unblocked);
}
#ifdef __linux__
else
#endif
#endif
- r = poll(p->pollfd, p->n_pollfd_used, p->timer_enabled ? (timeout.tv_sec*1000) + (timeout.tv_usec / 1000) : -1);
+ r = poll(p->pollfd, p->n_pollfd_used, (!wait || p->quit || p->timer_enabled) ? (timeout.tv_sec*1000) + (timeout.tv_usec / 1000) : -1);
if (r < 0) {
if (errno == EAGAIN || errno == EINTR)
@@ -407,21 +403,6 @@
pa_log_error("poll(): %s", pa_cstrerror(errno));
reset_all_revents(p);
- }
-
- if (p->timer_enabled) {
- if (p->period > 0) {
- struct timeval now;
- pa_rtclock_get(&now);
-
- pa_timeval_add(&p->next_elapse, p->period);
-
- /* Guarantee that the next timeout will happen in the future */
- if (pa_timeval_cmp(&p->next_elapse, &now) < 0)
- pa_timeval_add(&p->next_elapse, (pa_timeval_diff(&now, &p->next_elapse) / p->period + 1) * p->period);
-
- } else
- p->timer_enabled = FALSE;
}
/* Let's tell everyone that we left the sleep */
@@ -489,15 +470,8 @@
/* Make sure that 0,0 is not understood as
* "disarming" */
- if (its.it_value.tv_sec == 0)
+ if (its.it_value.tv_sec == 0 && its.it_value.tv_nsec == 0)
its.it_value.tv_nsec = 1;
-
- if (p->period > 0) {
- struct timeval tv;
- pa_timeval_store(&tv, p->period);
- its.it_interval.tv_sec = tv.tv_sec;
- its.it_interval.tv_nsec = tv.tv_usec*1000;
- }
}
pa_assert_se(timer_settime(p->timer, TIMER_ABSTIME, &its, NULL) == 0);
@@ -515,16 +489,14 @@
pa_assert(ts);
p->next_elapse = *ts;
- p->period = 0;
p->timer_enabled = TRUE;
update_timer(p);
}
-void pa_rtpoll_set_timer_periodic(pa_rtpoll *p, pa_usec_t usec) {
- pa_assert(p);
-
- p->period = usec;
+void pa_rtpoll_set_timer_relative(pa_rtpoll *p, pa_usec_t usec) {
+ pa_assert(p);
+
pa_rtclock_get(&p->next_elapse);
pa_timeval_add(&p->next_elapse, usec);
p->timer_enabled = TRUE;
@@ -532,21 +504,9 @@
update_timer(p);
}
-void pa_rtpoll_set_timer_relative(pa_rtpoll *p, pa_usec_t usec) {
- pa_assert(p);
-
- p->period = 0;
- pa_rtclock_get(&p->next_elapse);
- pa_timeval_add(&p->next_elapse, usec);
- p->timer_enabled = TRUE;
-
- update_timer(p);
-}
-
void pa_rtpoll_set_timer_disabled(pa_rtpoll *p) {
pa_assert(p);
- p->period = 0;
memset(&p->next_elapse, 0, sizeof(p->next_elapse));
p->timer_enabled = FALSE;
Modified: branches/glitch-free/src/pulsecore/rtpoll.h
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/glitch-free/src/pulsecore/rtpoll.h?rev=2217&root=pulseaudio&r1=2216&r2=2217&view=diff
==============================================================================
--- branches/glitch-free/src/pulsecore/rtpoll.h (original)
+++ branches/glitch-free/src/pulsecore/rtpoll.h Fri Apr 4 18:05:15 2008
@@ -75,7 +75,6 @@
int pa_rtpoll_run(pa_rtpoll *f, pa_bool_t wait);
void pa_rtpoll_set_timer_absolute(pa_rtpoll *p, const struct timeval *ts);
-void pa_rtpoll_set_timer_periodic(pa_rtpoll *p, pa_usec_t usec);
void pa_rtpoll_set_timer_relative(pa_rtpoll *p, pa_usec_t usec);
void pa_rtpoll_set_timer_disabled(pa_rtpoll *p);
More information about the pulseaudio-commits
mailing list