From b599d3c836c7a5c4c665339279a47da8be914789 Mon Sep 17 00:00:00 2001 From: Maarten Bosmans Date: Tue, 15 Mar 2011 21:06:46 +0100 Subject: Fix pa_rtclock_from_wallclock The HAVE_CLOCK_GETTIME macro protects timespec and related functions, nothing of which is used in pa_rtclock_from_wallclock. And silently just not converting was not the proper solution anyway. Also add an assert in pulse/mainloop.c to report the integer overflow that was triggered by the wrong pa_rtclock_from_wallclock. Without the assert, debugging was painful. --- src/pulsecore/core-rtclock.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'src/pulsecore/core-rtclock.c') diff --git a/src/pulsecore/core-rtclock.c b/src/pulsecore/core-rtclock.c index ac2c097a..331ac112 100644 --- a/src/pulsecore/core-rtclock.c +++ b/src/pulsecore/core-rtclock.c @@ -182,15 +182,13 @@ void pa_rtclock_hrtimer_enable(void) { } struct timeval* pa_rtclock_from_wallclock(struct timeval *tv) { - -#ifdef HAVE_CLOCK_GETTIME struct timeval wc_now, rt_now; + pa_assert(tv); + pa_gettimeofday(&wc_now); pa_rtclock_get(&rt_now); - pa_assert(tv); - /* pa_timeval_sub() saturates on underflow! */ if (pa_timeval_cmp(&wc_now, tv) < 0) @@ -199,7 +197,6 @@ struct timeval* pa_rtclock_from_wallclock(struct timeval *tv) { pa_timeval_sub(&rt_now, pa_timeval_diff(&wc_now, tv)); *tv = rt_now; -#endif return tv; } @@ -232,15 +229,13 @@ struct timespec* pa_timespec_store(struct timespec *ts, pa_usec_t v) { #endif static struct timeval* wallclock_from_rtclock(struct timeval *tv) { - -#ifdef HAVE_CLOCK_GETTIME struct timeval wc_now, rt_now; + pa_assert(tv); + pa_gettimeofday(&wc_now); pa_rtclock_get(&rt_now); - pa_assert(tv); - /* pa_timeval_sub() saturates on underflow! */ if (pa_timeval_cmp(&rt_now, tv) < 0) @@ -249,7 +244,6 @@ static struct timeval* wallclock_from_rtclock(struct timeval *tv) { pa_timeval_sub(&wc_now, pa_timeval_diff(&rt_now, tv)); *tv = wc_now; -#endif return tv; } -- cgit