diff options
author | Lennart Poettering <lennart@poettering.net> | 2009-02-20 21:39:46 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2009-02-20 21:39:46 +0100 |
commit | ed67b07c4189e33223f1fb981a519a1af2992ebc (patch) | |
tree | adc7d7af74c752fd1d64a2a0e9056174b18be25b /src/pulsecore | |
parent | 9f89907bfa671a5d924c3fe1acd1ea433a87fc71 (diff) |
simplify some code
Diffstat (limited to 'src/pulsecore')
-rw-r--r-- | src/pulsecore/rtpoll.c | 77 |
1 files changed, 37 insertions, 40 deletions
diff --git a/src/pulsecore/rtpoll.c b/src/pulsecore/rtpoll.c index 01dfd620..aa8ca321 100644 --- a/src/pulsecore/rtpoll.c +++ b/src/pulsecore/rtpoll.c @@ -478,59 +478,56 @@ static void update_timer(pa_rtpoll *p) { #ifdef HAVE_PPOLL #ifdef __linux__ - if (!p->dont_use_ppoll) { + if (p->dont_use_ppoll) + return; #endif - if (p->timer == (timer_t) -1) { - struct sigevent se; - - memset(&se, 0, sizeof(se)); - se.sigev_notify = SIGEV_SIGNAL; - se.sigev_signo = p->rtsig; + if (p->timer == (timer_t) -1) { + struct sigevent se; - if (timer_create(CLOCK_MONOTONIC, &se, &p->timer) < 0) - if (timer_create(CLOCK_REALTIME, &se, &p->timer) < 0) { - pa_log_warn("Failed to allocate POSIX timer: %s", pa_cstrerror(errno)); - p->timer = (timer_t) -1; - } - } + memset(&se, 0, sizeof(se)); + se.sigev_notify = SIGEV_SIGNAL; + se.sigev_signo = p->rtsig; - if (p->timer != (timer_t) -1) { - struct itimerspec its; - struct timespec ts = { .tv_sec = 0, .tv_nsec = 0 }; - sigset_t ss; + if (timer_create(CLOCK_MONOTONIC, &se, &p->timer) < 0) + if (timer_create(CLOCK_REALTIME, &se, &p->timer) < 0) { + pa_log_warn("Failed to allocate POSIX timer: %s", pa_cstrerror(errno)); + p->timer = (timer_t) -1; + } + } - if (p->timer_armed) { - /* First disarm timer */ - memset(&its, 0, sizeof(its)); - pa_assert_se(timer_settime(p->timer, TIMER_ABSTIME, &its, NULL) == 0); + if (p->timer != (timer_t) -1) { + struct itimerspec its; + struct timespec ts = { .tv_sec = 0, .tv_nsec = 0 }; + sigset_t ss; - /* Remove a signal that might be waiting in the signal q */ - pa_assert_se(sigemptyset(&ss) == 0); - pa_assert_se(sigaddset(&ss, p->rtsig) == 0); - sigtimedwait(&ss, NULL, &ts); - } + if (p->timer_armed) { + /* First disarm timer */ + memset(&its, 0, sizeof(its)); + pa_assert_se(timer_settime(p->timer, TIMER_ABSTIME, &its, NULL) == 0); - /* And install the new timer */ - if (p->timer_enabled) { - memset(&its, 0, sizeof(its)); + /* Remove a signal that might be waiting in the signal q */ + pa_assert_se(sigemptyset(&ss) == 0); + pa_assert_se(sigaddset(&ss, p->rtsig) == 0); + sigtimedwait(&ss, NULL, &ts); + } - its.it_value.tv_sec = p->next_elapse.tv_sec; - its.it_value.tv_nsec = p->next_elapse.tv_usec*1000; + /* And install the new timer */ + if (p->timer_enabled) { + memset(&its, 0, sizeof(its)); - /* Make sure that 0,0 is not understood as - * "disarming" */ - if (its.it_value.tv_sec == 0 && its.it_value.tv_nsec == 0) - its.it_value.tv_nsec = 1; - pa_assert_se(timer_settime(p->timer, TIMER_ABSTIME, &its, NULL) == 0); - } + its.it_value.tv_sec = p->next_elapse.tv_sec; + its.it_value.tv_nsec = p->next_elapse.tv_usec*1000; - p->timer_armed = p->timer_enabled; + /* Make sure that 0,0 is not understood as + * "disarming" */ + if (its.it_value.tv_sec == 0 && its.it_value.tv_nsec == 0) + its.it_value.tv_nsec = 1; + pa_assert_se(timer_settime(p->timer, TIMER_ABSTIME, &its, NULL) == 0); } -#ifdef __linux__ + p->timer_armed = p->timer_enabled; } -#endif #endif } |