From: Andre Noll Date: Thu, 12 Mar 2009 20:39:59 +0000 (+0100) Subject: vss: Take fec group durations into account when computing the eof barrier. X-Git-Tag: v0.3.4~38 X-Git-Url: http://git.tue.mpg.de/?a=commitdiff_plain;h=027e2ddb3ca6e8b29ec826f529cd66bc4447f32f;p=paraslash.git vss: Take fec group durations into account when computing the eof barrier. On eof, we must wait at least as long as the duration of the last sent fec group. --- diff --git a/vss.c b/vss.c index 37a80759..e1a3c374 100644 --- a/vss.c +++ b/vss.c @@ -458,6 +458,24 @@ static void compute_slice_timeout(struct timeval *timeout) } } +static void set_eof_barrier(struct vss_task *vsst) +{ + struct fec_client *fc; + struct timeval timeout = mmd->afd.afhi.eof_tv, + *chunk_tv = vss_chunk_time(); + + if (!chunk_tv) + goto out; + list_for_each_entry(fc, &fec_client_list, node) { + struct timeval group_duration; + tv_scale(fc->group.num_chunks, chunk_tv, &group_duration); + if (tv_diff(&timeout, &group_duration, NULL) < 0) + timeout = group_duration; + } +out: + tv_add(now, &timeout, &vsst->eof_barrier); +} + /** * Check if vss status flag \a P (playing) is set. * @@ -574,7 +592,7 @@ static void vss_eof(struct vss_task *vsst) return; if (mmd->new_vss_status_flags & VSS_NOMORE) mmd->new_vss_status_flags = VSS_NEXT; - tv_add(&mmd->afd.afhi.eof_tv, now, &vsst->eof_barrier); + set_eof_barrier(vsst); para_munmap(vsst->map, mmd->size); vsst->map = NULL; mmd->chunks_sent = 0; @@ -658,11 +676,11 @@ static void vss_pre_select(struct sched *s, struct task *t) vss_eof(vsst); else if (vss_paused()) { if (mmd->chunks_sent) - tv_add(&mmd->afd.afhi.eof_tv, now, &vsst->eof_barrier); + set_eof_barrier(vsst); mmd->chunks_sent = 0; } else if (vss_repos()) { tv_add(now, &vsst->announce_tv, &vsst->data_send_barrier); - tv_add(&mmd->afd.afhi.eof_tv, now, &vsst->eof_barrier); + set_eof_barrier(vsst); mmd->chunks_sent = 0; mmd->current_chunk = mmd->repos_request; mmd->new_vss_status_flags &= ~VSS_REPOS;