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 499c0a88931d1712bff7c3b57fef5fa75c075be8..d5593f25d02c5cde248e0c775a1d3235a279ef8f 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 06eb8b30f617104051fb3260e5b17c261a04ec17..7cdc5e078b360fbb9730e9e5f79b9306c2f6d9fb 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 759caa3d5646bf15d0b71cec0bb6932149a7c3c3..edbd7c3993bb5f4b3eb18a0efc9f1233e3d9da83 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 ef3b1742decb54c69bf3d91857695e97ea4b6374..481c0b68e19fb342489736c3f2c36d6e92eb9b1c 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;
 }