jitterbuffer: make sure time never goes invalid

Since the skew can be negative, we might end up with invalid timestamps. Check
for negative results and clamp to 0.

See #593354
This commit is contained in:
Wim Taymans 2009-08-31 12:47:15 +02:00
parent 1f14f577d8
commit e254936e34

View file

@ -343,7 +343,13 @@ no_skew:
/* the output time is defined as the base timestamp plus the RTP time /* the output time is defined as the base timestamp plus the RTP time
* adjusted for the clock skew .*/ * adjusted for the clock skew .*/
if (jbuf->base_time != -1) { if (jbuf->base_time != -1) {
out_time = jbuf->base_time + send_diff + jbuf->skew; out_time = jbuf->base_time + send_diff;
/* skew can be negative and we don't want to make invalid timestamps */
if (jbuf->skew < 0 && out_time < -jbuf->skew) {
out_time = 0;
} else {
out_time += jbuf->skew;
}
/* check if timestamps are not going backwards, we can only check this if we /* check if timestamps are not going backwards, we can only check this if we
* have a previous out time and a previous send_diff */ * have a previous out time and a previous send_diff */
if (G_LIKELY (jbuf->prev_out_time != -1 && jbuf->prev_send_diff != -1)) { if (G_LIKELY (jbuf->prev_out_time != -1 && jbuf->prev_send_diff != -1)) {