[pulseaudio-discuss] [PATCH] Correctly deal with events in the past in calc_next_timeout

Maxim Levitsky maximlevitsky at gmail.com
Sat Aug 8 17:01:08 PDT 2009


Correctly deal with events in the past in calc_next_timeout
This fixes a gstreamer mixer regression, when it can't control the volume,
after few changes.

From: Maxim Levitsky <maximlevitsky at gmail.com>

pa_usec_t is unsigned, thus it will always be >= 0
This makes gstreamer pulse mixer work again
---

 src/pulse/mainloop.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)


diff --git a/src/pulse/mainloop.c b/src/pulse/mainloop.c
index c418d10..fb5f148 100644
--- a/src/pulse/mainloop.c
+++ b/src/pulse/mainloop.c
@@ -765,7 +765,7 @@ 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;
@@ -776,12 +776,12 @@ static int calc_next_timeout(pa_mainloop *m) {
     if (t->time == 0)
         return 0;
 
-    usec = t->time - pa_rtclock_now();
+    clock_now = pa_rtclock_now();
 
-    if (usec <= 0)
-        return 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) {





More information about the pulseaudio-discuss mailing list