Add missing regex include to generated command_list files.
[paraslash.git] / fecdec_filter.c
index 30ac818c360873f6aedadd19e55ca7e0f6209550..7fe8743794d38540ce132218fa8f6cc41ae1727f 100644 (file)
@@ -6,6 +6,8 @@
 
 /** \file fecdec_filter.c A filter fec-decodes an audio stream. */
 
+#include <regex.h>
+
 #include <dirent.h>
 #include "para.h"
 #include "error.h"
@@ -28,7 +30,7 @@
 #define NUM_FEC_GROUPS 3
 
 /** Default size of the output buffer of the fecdec filter. */
-#define FECDEC_DEFAULT_OUTBUF_SIZE (16 * 1024)
+#define FECDEC_DEFAULT_OUTBUF_SIZE (3 * 1024)
 /** Maximal size of the output buffer of the fecdec filter. */
 #define FECDEC_MAX_OUTBUF_SIZE (1024 * 1024)
 
@@ -78,6 +80,7 @@ struct private_fecdec_data {
        struct fec_parms *fec;
        /** Keeps track of what was received so far. */
        struct fecdec_group groups[NUM_FEC_GROUPS];
+       /** Whether an audio file header was already received. */
        int have_header;
 };
 
@@ -119,10 +122,15 @@ static int find_group(struct fec_header *h,
        FOR_EACH_FECDEC_GROUP(fg, pfd) {
                if (fg->h.group_num != h->group_num)
                        continue;
+               if (fg->num_received_slices == 0)
+                       goto success;
                if (fg->h.slices_per_group != h->slices_per_group)
-                       continue;
+                       return -E_BAD_FEC_HEADER;
                if (fg->h.data_slices_per_group != h->data_slices_per_group)
-                       continue;
+                       return -E_BAD_FEC_HEADER;
+               if (fg->h.group_bytes != h->group_bytes)
+                       return -E_BAD_FEC_HEADER;
+success:
                *result = fg;
                return 1;
        }
@@ -163,8 +171,8 @@ static struct fecdec_group *free_oldest_group(struct private_fecdec_data *pfd)
        }
        if (!group_complete(oldest) && !group_empty(oldest))
                PARA_WARNING_LOG("Clearing incomplete group %d "
-                       "(contains %d slices)\n", fg->h.group_num,
-                       fg->num_received_slices);
+                       "(contains %d slices)\n", oldest->h.group_num,
+                       oldest->num_received_slices);
        clear_group(oldest);
        return oldest;
 }
@@ -366,7 +374,7 @@ static ssize_t fecdec(char *buf, size_t len, struct filter_node *fn)
        ret = read_fec_header(buf, len, &h);
        if (ret <= 0)
                return ret;
-       if (!h.slice_bytes || h.slice_bytes > fn->bufsize)
+       if (!h.slice_bytes)
                return -E_BAD_SLICE_SIZE;
        if (h.slice_num > h.slices_per_group)
                return -E_BAD_SLICE_NUM;