summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTanu Kaskinen <tanuk@iki.fi>2017-05-02 16:44:29 +0300
committerTanu Kaskinen <tanuk@iki.fi>2017-05-02 16:53:40 +0300
commit4e3aa53a3f8b5d81441ee0f3d61fc2d1db57908f (patch)
tree593c1128eaf80b90cc6aba04541a8d99bf471261
parent1c477fcb679ac50259ef057ebe23c80c529aa612 (diff)
jack-sink: fix latency calculation
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.
-rw-r--r--src/modules/jack/module-jack-sink.c6
1 files 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 */