From: Andre Noll Date: Wed, 4 Mar 2009 21:19:04 +0000 (+0100) Subject: Recognize the eof packet also in the udp receiver. X-Git-Tag: v0.3.4~55 X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=commitdiff_plain;h=ac153fd54a0f093581ee863984070a325d5343b8;hp=e77825db70787c9ddbbee3827e2bf6e4452ad7a4 Recognize the eof packet also in the udp receiver. 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. --- diff --git a/fecdec_filter.c b/fecdec_filter.c index 499c0a88..d5593f25 100644 --- a/fecdec_filter.c +++ b/fecdec_filter.c @@ -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 06eb8b30..7cdc5e07 100644 --- 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 diff --git a/udp_recv.c b/udp_recv.c index 759caa3d..edbd7c39 100644 --- a/udp_recv.c +++ b/udp_recv.c @@ -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 ef3b1742..481c0b68 100644 --- 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; }