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

Lennart Poettering lennart at poettering.net
Mon Aug 10 12:26:17 PDT 2009


On Sun, 09.08.09 03:01, Maxim Levitsky (maximlevitsky at gmail.com) wrote:

> 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.

Thanks for the patch! Merged! Amazing how this one managed to stay
unnoticed for so long.

Sorry for not responding earlier. Patches I need to read more
carefully than normal emails, so it takes a few day usually until I
find enough time to do so. Generally, I try to leave no email
unanswered.

Lennart

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


Lennart

-- 
Lennart Poettering                        Red Hat, Inc.
lennart [at] poettering [dot] net
http://0pointer.net/lennart/           GnuPG 0x1A015CC4



More information about the pulseaudio-discuss mailing list