]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - vss.c
alsa_write: Handle EPIPE errors properly.
[paraslash.git] / vss.c
diff --git a/vss.c b/vss.c
index dc5989365120855ace93a38b9502c82947807411..d0e1cf53242a52bbdcef4b486136747239784734 100644 (file)
--- a/vss.c
+++ b/vss.c
@@ -238,6 +238,9 @@ static int setup_next_fec_group(struct fec_client *fc, struct vss_task *vsst)
        fc->group.num_chunks = i - fc->group.first_chunk;
        fc->slice.num = 0;
        fc->slice.bytes = ROUND_UP(fc->group.bytes, k) / k;
+       /* FIXME: Avoid division by zero in a better way */
+       if (!fc->slice.bytes)
+               return 0;
 
        /* The last slice will not be fully used */
        last_payload_size = fc->group.bytes % fc->slice.bytes;
@@ -304,11 +307,7 @@ static int compute_next_fec_slice(struct fec_client *fc, struct vss_task *vsst)
  */
 size_t vss_get_fec_eof_packet(const char **buf)
 {
-       static const char fec_eof_packet[FEC_HEADER_SIZE] =
-       "\xec\x0d\xcc\xfe\0\0\0\0"
-       "\0\0\0\0\0\0\0\0"
-       "\0\0\0\0\0\0\0\0"
-       "\0\0\0\0\0\0\0\0";
+       static const char fec_eof_packet[FEC_HEADER_SIZE] = FEC_EOF_PACKET;
        *buf = fec_eof_packet;
        return FEC_HEADER_SIZE;
 }
@@ -771,7 +770,7 @@ static void vss_send(struct vss_task *vsst)
                        continue;
                if (!compute_next_fec_slice(fc, vsst))
                        continue;
-               PARA_DEBUG_LOG("sending %d:%d (%zu bytes)\n", fc->group.num,
+               PARA_DEBUG_LOG("sending %d:%d (%u bytes)\n", fc->group.num,
                        fc->slice.num, fc->slice.bytes);
                fc->fcp->send((char *)fc->enc_buf,
                        fc->slice.bytes + FEC_HEADER_SIZE,
@@ -838,6 +837,7 @@ void init_vss_task(int afs_socket)
        vsst->task.post_select = vss_post_select;
        ms2tv(announce_time, &vsst->announce_tv);
        PARA_INFO_LOG("announce timeval: %lums\n", tv2ms(&vsst->announce_tv));
+       INIT_LIST_HEAD(&fec_client_list);
        for (i = 0; senders[i].name; i++) {
                PARA_NOTICE_LOG("initializing %s sender\n", senders[i].name);
                senders[i].init(&senders[i]);
@@ -855,6 +855,5 @@ void init_vss_task(int afs_socket)
                tv_add(&vsst->autoplay_barrier, &vsst->announce_tv,
                        &vsst->data_send_barrier);
        }
-       INIT_LIST_HEAD(&fec_client_list);
        register_task(&vsst->task);
 }