From 23a294c97e62e0bee9b17b1f8ad20a39e1ba15da Mon Sep 17 00:00:00 2001 From: Maxim Levitsky Date: Sun, 9 Aug 2009 03:01:08 +0300 Subject: Correctly deal with events in the past in calc_next_timeout pa_usec_t is unsigned, thus it will always be >= 0 This makes gstreamer pulse mixer work again This fixes a gstreamer mixer regression, when it can't control the volume, after few changes. --- src/pulse/mainloop.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'src/pulse') diff --git a/src/pulse/mainloop.c b/src/pulse/mainloop.c index c418d108..93a4742d 100644 --- a/src/pulse/mainloop.c +++ b/src/pulse/mainloop.c @@ -765,23 +765,22 @@ static pa_time_event* find_next_time_event(pa_mainloop *m) { static int calc_next_timeout(pa_mainloop *m) { pa_time_event *t; - pa_usec_t usec; + pa_usec_t clock_now; if (!m->n_enabled_time_events) return -1; - t = find_next_time_event(m); - pa_assert(t); + pa_assert_se(t = find_next_time_event(m)); - if (t->time == 0) + if (t->time <= 0) return 0; - usec = t->time - pa_rtclock_now(); + clock_now = pa_rtclock_now(); - if (usec <= 0) + if (t->time <= clock_now) return 0; - return (int) (usec / 1000); /* in milliseconds */ + return (int) ((t->time - clock_now) / 1000); /* in milliseconds */ } static int dispatch_timeout(pa_mainloop *m) { -- cgit