diff --git a/src/input/mpegts/satip/satip_frontend.c b/src/input/mpegts/satip/satip_frontend.c index f973a657..fdca0d6b 100644 --- a/src/input/mpegts/satip/satip_frontend.c +++ b/src/input/mpegts/satip/satip_frontend.c @@ -864,7 +864,8 @@ static void * satip_frontend_input_thread ( void *aux ) { #define RTP_PKTS 64 -#define RTP_PKT_SIZE 1472 /* this is maximum UDP payload (standard ethernet) */ +#define UDP_PKT_SIZE 1472 /* this is maximum UDP payload (standard ethernet) */ +#define RTP_PKT_SIZE (UDP_PKT_SIZE - 12) /* minus RTP minimal RTP header */ #define HTTP_CMD_NONE 9874 satip_frontend_t *lfe = aux, *lfe2; mpegts_mux_instance_t *mmi = lfe->sf_mmi; @@ -933,7 +934,7 @@ satip_frontend_input_thread ( void *aux ) } udp_multirecv_init(&um, RTP_PKTS, RTP_PKT_SIZE); - sbuf_init_fixed(&sb, 18800); + sbuf_init_fixed(&sb, RTP_PKTS * RTP_PKT_SIZE); while (tvheadend_running && !fatal) { @@ -1079,9 +1080,9 @@ satip_frontend_input_thread ( void *aux ) seq = nseq; /* Process */ sbuf_append(&sb, p + pos, c - pos); - mpegts_input_recv_packets((mpegts_input_t*)lfe, mmi, - &sb, 0, NULL, NULL); } + mpegts_input_recv_packets((mpegts_input_t*)lfe, mmi, + &sb, 0, NULL, NULL); } sbuf_free(&sb); diff --git a/src/udp.c b/src/udp.c index a0789f09..35ec2fcf 100644 --- a/src/udp.c +++ b/src/udp.c @@ -386,13 +386,10 @@ udp_write_queue( udp_connection_t *uc, htsbuf_queue_t *q, * UDP multi packet receive support */ -#ifndef CONFIG_RECVMMSG - -#ifdef __linux__ - +#if !defined (CONFIG_RECVMMSG) && defined(__linux__) /* define the syscall - works only for linux */ - #include +#ifdef __NR_recvmmsg struct mmsghdr { struct msghdr msg_hdr; @@ -402,38 +399,44 @@ struct mmsghdr { int recvmmsg(int sockfd, struct mmsghdr *msgvec, unsigned int vlen, unsigned int flags, struct timespec *timeout); -#ifdef __NR_recvmmsg - int recvmmsg(int sockfd, struct mmsghdr *msgvec, unsigned int vlen, unsigned int flags, struct timespec *timeout) { return syscall(__NR_recvmmsg, sockfd, msgvec, vlen, flags, timeout); } -#else +#define CONFIG_RECVMMSG -#undef PKTS -#define PKTS 1 -/* receive only single packet */ -int recvmmsg(int sockfd, struct mmsghdr *msgvec, unsigned int vlen, - unsigned int flags, struct timespec *timeout) +#endif +#endif + + +#ifndef CONFIG_RECVMMSG + +struct mmsghdr { + struct msghdr msg_hdr; + unsigned int msg_len; +}; + +static int +recvmmsg(int sockfd, struct mmsghdr *msgvec, unsigned int vlen, + unsigned int flags, struct timespec *timeout) { - ssize_t r = recvmsg(sockfd, &msgvec->msg_hdr, flags); - if (r < 0) - return r; - msgvec->msg_len = r; - return 1; + ssize_t r; + unsigned int i; + + for (i = 0; i < vlen; i++) { + r = recvmsg(sockfd, &msgvec->msg_hdr, flags); + if (r < 0) + return (i > 0) ? i : r; + msgvec->msg_len = r; + msgvec++; + } + return i; } #endif -#else /* not __linux__ */ - -#error "Add recvmmsg() support for your platform!!!" - -#endif - -#endif /* !CONFIG_RECVMMSG */ void udp_multirecv_init( udp_multirecv_t *um, int packets, int psize )