vss: Take fec group durations into account when computing the eof barrier.
authorAndre Noll <maan@systemlinux.org>
Thu, 12 Mar 2009 20:39:59 +0000 (21:39 +0100)
committerAndre Noll <maan@systemlinux.org>
Thu, 12 Mar 2009 20:39:59 +0000 (21:39 +0100)
On eof, we must wait at least as long as the duration of the last sent
fec group.

vss.c

diff --git a/vss.c b/vss.c
index 37a8075..e1a3c37 100644 (file)
--- 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;