diff options
author | phintuka <phintuka> | 2009-07-24 18:02:51 +0000 |
---|---|---|
committer | phintuka <phintuka> | 2009-07-24 18:02:51 +0000 |
commit | 7e1689816d6ca2dacc36ba20f9db79693529553f (patch) | |
tree | f26c5237a8505b6d2a3405e9ecb76df54d5160ff | |
parent | 8185683af5fb3a800da3b517c5bc91257b5dcf70 (diff) | |
download | xineliboutput-7e1689816d6ca2dacc36ba20f9db79693529553f.tar.gz xineliboutput-7e1689816d6ca2dacc36ba20f9db79693529553f.tar.bz2 |
Simplify
-rw-r--r-- | tools/backgroundwriter.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/tools/backgroundwriter.c b/tools/backgroundwriter.c index ad0a6ddb..14c57e33 100644 --- a/tools/backgroundwriter.c +++ b/tools/backgroundwriter.c @@ -4,7 +4,7 @@ * See the main source file 'xineliboutput.c' for copyright information and * how to reach the author. * - * $Id: backgroundwriter.c,v 1.16 2009-07-24 05:24:22 phintuka Exp $ + * $Id: backgroundwriter.c,v 1.17 2009-07-24 18:02:51 phintuka Exp $ * */ @@ -195,14 +195,16 @@ void cTcpWriter::Action(void) if(Count < (int)sizeof(stream_tcp_header_t)) LOGMSG("cBackgroundWriter @NextHeaderPos: Count < header size !"); + // limit single write to size of next (complete) packet. + // (we need to track packet boundaries) stream_tcp_header_t *header = (stream_tcp_header_t*)Data; - if(Count < (int)(ntohl(header->len) + sizeof(stream_tcp_header_t))) - ;//LOGMSG("Count = %d < %d", Count, - // header->len + sizeof(stream_tcp_header_t)); - else - Count = ntohl(header->len) + sizeof(stream_tcp_header_t); - NextHeaderPos = GetPos + ntohl(header->len) + sizeof(stream_tcp_header_t); + int pkt_len = ntohl(header->len) + sizeof(stream_tcp_header_t); + if (Count > pkt_len) + Count = pkt_len; + // next packet start position in stream + NextHeaderPos = GetPos + pkt_len; + // check for control message uint8_t *pkt = TCP_PAYLOAD(Data); if (!DATA_IS_PES(pkt) && !DATA_IS_TS(pkt)) CorkReq = true; |