]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - vss.c
audiod: Change return value of open_current_receiver() to void.
[paraslash.git] / vss.c
diff --git a/vss.c b/vss.c
index a8486bbd9e86e64b6734117386ab5fcca83bd26a..37a80759e17a09bb2bd21ab8c6678985e5e0da25 100644 (file)
--- a/vss.c
+++ b/vss.c
@@ -209,7 +209,7 @@ static int need_audio_header(struct fec_client *fc, struct vss_task *vsst)
                return 0;
        if (!vsst->header_len)
                return 0;
-       if (fc->group.num && tv_diff(&fc->next_header_time, now, NULL) < 0)
+       if (fc->group.num && tv_diff(&fc->next_header_time, now, NULL) > 0)
                return 0;
        tv_add(now, &vsst->header_interval, &fc->next_header_time);
        return 1;
@@ -340,8 +340,9 @@ static int compute_next_fec_slice(struct fec_client *fc, struct vss_task *vsst)
 {
        if (fc->first_stream_chunk < 0 || fc->current_slice_num
                        == fc->fcp->slices_per_group + fc->num_extra_slices) {
-               if (!setup_next_fec_group(fc, vsst))
-                       return 0;
+               int ret = setup_next_fec_group(fc, vsst);
+               if (ret <= 0)
+                       return ret;
        }
        write_fec_header(fc, vsst);
        fec_encode(fc->parms, fc->src_data, fc->enc_buf + FEC_HEADER_SIZE,
@@ -780,7 +781,7 @@ err:
  */
 static void vss_send(struct vss_task *vsst)
 {
-       int i;
+       int i, sent_something = 0;
        struct timeval due;
        struct fec_client *fc, *tmp_fc;
 
@@ -791,8 +792,22 @@ static void vss_send(struct vss_task *vsst)
        if (chk_barrier("data send", &vsst->data_send_barrier,
                        &due, 1) < 0)
                return;
+       list_for_each_entry_safe(fc, tmp_fc, &fec_client_list, node) {
+               if (!next_slice_is_due(fc, NULL))
+                       continue;
+               if (compute_next_fec_slice(fc, vsst) <= 0)
+                       continue;
+               PARA_DEBUG_LOG("sending %d:%d (%u bytes)\n", fc->group.num,
+                       fc->current_slice_num, fc->fcp->max_slice_bytes);
+               fc->fcp->send((char *)fc->enc_buf,
+                       fc->fcp->max_slice_bytes,
+                       fc->fcp->private_data);
+               fc->current_slice_num++;
+               sent_something = 1;
+       }
        if (mmd->current_chunk >= mmd->afd.afhi.chunks_total) { /* eof */
-               mmd->new_vss_status_flags |= VSS_NEXT;
+               if (!sent_something)
+                       mmd->new_vss_status_flags |= VSS_NEXT;
                return;
        }
        compute_chunk_time(mmd->chunks_sent, &mmd->afd.afhi.chunk_tv,
@@ -824,18 +839,6 @@ static void vss_send(struct vss_task *vsst)
                mmd->chunks_sent++;
                mmd->current_chunk++;
        }
-       list_for_each_entry_safe(fc, tmp_fc, &fec_client_list, node) {
-               if (!next_slice_is_due(fc, NULL))
-                       continue;
-               if (!compute_next_fec_slice(fc, vsst))
-                       continue;
-               PARA_DEBUG_LOG("sending %d:%d (%u bytes)\n", fc->group.num,
-                       fc->current_slice_num, fc->fcp->max_slice_bytes);
-               fc->fcp->send((char *)fc->enc_buf,
-                       fc->fcp->max_slice_bytes,
-                       fc->fcp->private_data);
-               fc->current_slice_num++;
-       }
 }
 
 static void vss_post_select(struct sched *s, struct task *t)