Recognize the eof packet also in the udp receiver.
authorAndre Noll <maan@systemlinux.org>
Wed, 4 Mar 2009 21:19:04 +0000 (22:19 +0100)
committerAndre Noll <maan@systemlinux.org>
Wed, 4 Mar 2009 21:19:04 +0000 (22:19 +0100)
This fixes two bugs: The last fec group of an audio file was not
decoded at all, and "para_recv -r udp" did not exit at the end of
a multicast stream.

fecdec_filter.c
para.h
udp_recv.c
vss.c

index 499c0a8..d5593f2 100644 (file)
@@ -267,7 +267,7 @@ static int read_fec_header(char *buf, size_t len, struct fec_header *h)
 
        h->slice_num = read_u8(buf + 18);
        h->slice_bytes = read_u16(buf + 20);
-       if (!h->group_bytes && & h->slice_bytes)
+       if (!memcmp(buf, FEC_EOF_PACKET, FEC_EOF_PACKET_LEN))
                return -E_FECDEC_EOF;
 //     PARA_DEBUG_LOG("group %u, slize %u, slices per group: %u\n",
 //             h->group_num, h->slice_num, h->slices_per_group);
diff --git a/para.h b/para.h
index 06eb8b3..7cdc5e0 100644 (file)
--- a/para.h
+++ b/para.h
@@ -250,3 +250,8 @@ static inline long int para_random(unsigned max)
  * horribly for characters which have their most significant bit set.
  */
 #define para_isspace(c) isspace((int)(unsigned char)(c))
+
+/** Data that indicates an eof-condition for a fec-encoded stream. */
+#define FEC_EOF_PACKET "\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"
+#define FEC_EOF_PACKET_LEN 32
index 759caa3..edbd7c3 100644 (file)
@@ -82,6 +82,9 @@ static void udp_recv_post_select(__a_unused struct sched *s, struct task *t)
        if (!ret)
                return;
        packet_size = ret;
+       if (packet_size >= FEC_EOF_PACKET_LEN)
+               if (!memcmp(tmpbuf, FEC_EOF_PACKET, FEC_EOF_PACKET_LEN))
+                       return;
        t->error = add_rn_output(rn, tmpbuf, packet_size);
        if (t->error < 0)
                return;
diff --git a/vss.c b/vss.c
index ef3b174..481c0b6 100644 (file)
--- a/vss.c
+++ b/vss.c
@@ -304,11 +304,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;
 }