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.
This commit is contained in:
Maxim Levitsky 2009-08-09 03:01:08 +03:00 committed by Lennart Poettering
parent 9bd3398f94
commit 23a294c97e

View file

@ -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) {