mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-10-31 22:25:33 -04:00
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.
This commit is contained in:
parent
c470680e1b
commit
b599d3c836
2 changed files with 18 additions and 19 deletions
|
|
@ -848,10 +848,15 @@ quit:
|
|||
}
|
||||
|
||||
static int usec_to_timeout(pa_usec_t u) {
|
||||
int timeout;
|
||||
|
||||
if (u == PA_USEC_INVALID)
|
||||
return -1;
|
||||
|
||||
return (u + PA_USEC_PER_MSEC - 1) / PA_USEC_PER_MSEC;
|
||||
timeout = (u + PA_USEC_PER_MSEC - 1) / PA_USEC_PER_MSEC;
|
||||
pa_assert(timeout >= 0);
|
||||
|
||||
return timeout;
|
||||
}
|
||||
|
||||
int pa_mainloop_poll(pa_mainloop *m) {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue