[PATCH] jack-sink: fix latency calculation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 02.05.2017 15:44, Tanu Kaskinen wrote:
> The compiler warned about number_of_frames being possibly used
> uninitialized, and on closer inspection I found that it was indeed not
> initialized if saved_frame_time_valid is false.
>
> In commit fe70b9e11a "source/sink: Allow pa_{source,
> sink}_get_latency_within_thread() to return negative values" the
> number_of_frames variable was added as an unsigned version of the l
> variable, and number_of_frames partially replaced the l variable. The
> replacement should have gone all the way, however. This patch removes
> the remaining uses of the l variable and substitutes number_of_frames
> on its place, and as a result, number_of_frames is now always
> initialized.
> ---
>   src/modules/jack/module-jack-sink.c | 6 +++---
>   1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/src/modules/jack/module-jack-sink.c b/src/modules/jack/module-jack-sink.c
> index 740538656..82bfccd91 100644
> --- a/src/modules/jack/module-jack-sink.c
> +++ b/src/modules/jack/module-jack-sink.c
> @@ -165,14 +165,14 @@ static int sink_process_msg(pa_msgobject *o, int code, void *data, int64_t offse
>               return 0;
>   
>           case PA_SINK_MESSAGE_GET_LATENCY: {
> -            jack_nframes_t l, ft, d;
> +            jack_nframes_t ft, d;
>               jack_latency_range_t r;
>               size_t n;
>               int32_t number_of_frames;
>   
>               /* This is the "worst-case" latency */
>               jack_port_get_latency_range(u->port[0], JackPlaybackLatency, &r);
> -            l = r.max + u->frames_in_buffer;
> +            number_of_frames = r.max + u->frames_in_buffer;
>   
>               if (u->saved_frame_time_valid) {
>                   /* Adjust the worst case latency by the time that
> @@ -180,7 +180,7 @@ static int sink_process_msg(pa_msgobject *o, int code, void *data, int64_t offse
>   
>                   ft = jack_frame_time(u->client);
>                   d = ft > u->saved_frame_time ? ft - u->saved_frame_time : 0;
> -                number_of_frames = (int32_t)l - d;
> +                number_of_frames -= d;
>               }
>   
>               /* Convert it to usec */

Looks good to me. Didn't see the warning somehow.



[Index of Archives]     [Linux Audio Users]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux