Skip to content

Commit

Permalink
loopback: Fix the obviously-wrong "buffer+=buffer" logic
Browse files Browse the repository at this point in the history
Originally pointed out by Georg Chini.

Calculating buffer = buffer + (send_counter - recv_counter)
in one branch and buffer = 2 * buffer - (recv_counter - send_counter)
looks very obviously wrong. In other words, before the patch, the
contribution from the previous lines was double-counted.
  • Loading branch information
patrakov authored and tanuk committed Sep 13, 2015
1 parent 11d22f9 commit c7310f8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/modules/module-loopback.c
Expand Up @@ -186,7 +186,7 @@ static void adjust_rates(struct userdata *u) {
if (u->latency_snapshot.recv_counter <= u->latency_snapshot.send_counter)
buffer += (size_t) (u->latency_snapshot.send_counter - u->latency_snapshot.recv_counter);
else
buffer += PA_CLIP_SUB(buffer, (size_t) (u->latency_snapshot.recv_counter - u->latency_snapshot.send_counter));
buffer = PA_CLIP_SUB(buffer, (size_t) (u->latency_snapshot.recv_counter - u->latency_snapshot.send_counter));

buffer_latency = pa_bytes_to_usec(buffer, &u->sink_input->sample_spec);

Expand Down

0 comments on commit c7310f8

Please sign in to comment.