diff options
author | Lennart Poettering <lennart@poettering.net> | 2009-09-18 04:11:59 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2009-09-18 04:14:39 +0200 |
commit | c024aeaae91c139914dc928df975ea311729052c (patch) | |
tree | be706c14d4cb32782ff44681afec066b895758da /src/pulsecore | |
parent | a1da83b206d4a73bfa537ab3694bac7244bd19a1 (diff) |
timeval: make timeval conversion routines handle PA_USEC_INVALID special
Diffstat (limited to 'src/pulsecore')
-rw-r--r-- | src/pulsecore/core-rtclock.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/pulsecore/core-rtclock.c b/src/pulsecore/core-rtclock.c index 7690ab70..1420470a 100644 --- a/src/pulsecore/core-rtclock.c +++ b/src/pulsecore/core-rtclock.c @@ -132,6 +132,8 @@ struct timeval* pa_rtclock_from_wallclock(struct timeval *tv) { pa_assert(tv); + /* pa_timeval_sub() saturates on underflow! */ + if (pa_timeval_cmp(&wc_now, tv) < 0) pa_timeval_add(&rt_now, pa_timeval_diff(tv, &wc_now)); else @@ -144,7 +146,9 @@ struct timeval* pa_rtclock_from_wallclock(struct timeval *tv) { } pa_usec_t pa_timespec_load(const struct timespec *ts) { - pa_assert(ts); + + if (PA_UNLIKELY(!ts)) + return PA_USEC_INVALID; return (pa_usec_t) ts->tv_sec * PA_USEC_PER_SEC + @@ -176,6 +180,8 @@ static struct timeval* wallclock_from_rtclock(struct timeval *tv) { pa_assert(tv); + /* pa_timeval_sub() saturates on underflow! */ + if (pa_timeval_cmp(&rt_now, tv) < 0) pa_timeval_add(&wc_now, pa_timeval_diff(tv, &rt_now)); else |