]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - fecdec_filter.c
fecdec: Add some more documentation, minor improvements.
[paraslash.git] / fecdec_filter.c
index 6aa9071e6ea1bbabcf5d874f07b67da71a06db20..6ca0b037da0f55be826137facc4632415648329c 100644 (file)
@@ -162,6 +162,7 @@ static struct fecdec_group *free_oldest_group(struct private_fecdec_data *pfd)
        return oldest;
 }
 
+/* returns 1 if the group was found, 0 if not, negative on errors */
 static int get_group(struct fec_header *h, struct private_fecdec_data *pfd,
                struct fecdec_group **result)
 {
@@ -175,24 +176,31 @@ static int get_group(struct fec_header *h, struct private_fecdec_data *pfd,
        /* group not found */
        fg = find_unused_group(pfd);
        if (fg)
-               goto update_header;
+               goto success;
        fg = try_to_free_group(pfd);
        if (fg)
-               goto update_header;
+               goto success;
        fg = free_oldest_group(pfd);
-update_header:
-       fg->h = *h;
+       ret = 0;
 success:
+       fg->h = *h;
        *result = fg;
-       return 1;
+       return ret;
 }
 
+/*
+ * returns 1 if slice was added, zero otherwise (because the group was already
+ * complete). In any case the number of received slices is being increased by
+ * one.
+ */
 static int add_slice(char *buf, struct fecdec_group *fg)
 {
        int r, slice_num;
 
-       if (group_complete(fg))
+       if (group_complete(fg)) {
+               fg->num_received_slices++;
                return 0;
+       }
        slice_num = fg->h.slice_num;
        if (fg->num_slices == 0) {
                fg->num_slices = fg->h.slices_per_group;
@@ -264,6 +272,7 @@ static int read_fec_header(char *buf, size_t len, struct fec_header *h)
        return 1;
 }
 
+/* returns 1 if we used the buffer, 0 if we didn't, negative on errors */
 static int dispatch_slice(char *buf, size_t len, struct fec_header *h,
                struct filter_node *fn)
 {
@@ -281,7 +290,6 @@ static int dispatch_slice(char *buf, size_t len, struct fec_header *h,
                        h->slice_num);
                return 1;
        }
-       fg->h = *h;
        ret = add_slice(buf, fg);
        if (ret < 0)
                return ret;