From a22254a4adb3db59e9807aca179fa7ebc49a8d12 Mon Sep 17 00:00:00 2001 From: phintuka Date: Tue, 21 Jul 2009 13:43:53 +0000 Subject: Avoid delaying control messages: Force TCP packet after control message, if there is no more data to the packet. --- tools/backgroundwriter.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tools/backgroundwriter.c b/tools/backgroundwriter.c index 0aeb32dd..6d8552df 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.14 2009-07-21 11:11:34 phintuka Exp $ + * $Id: backgroundwriter.c,v 1.15 2009-07-21 13:43:53 phintuka Exp $ * */ @@ -151,11 +151,18 @@ void cTcpWriter::Action(void) uint64_t NextHeaderPos = 0; uint64_t GetPos = 0; cPoller Poller (m_fd, true); + bool CorkReq = false; while(m_Active) { if(Poller.Poll(100)) { + if (CorkReq && m_RingBuffer.Available() <= 0) { + // Force TCP packet to avoid delaying control messages + Cork(); + CorkReq = false; + } + uint64_t StartPos; int Count = 0; int n; @@ -197,6 +204,11 @@ void cTcpWriter::Action(void) else Count = ntohl(header->len) + sizeof(stream_tcp_header_t); NextHeaderPos = GetPos + ntohl(header->len) + sizeof(stream_tcp_header_t); + + uint8_t *pkt = TCP_PAYLOAD(Data); + if (!DATA_IS_PES(pkt) && !DATA_IS_TS(pkt)) + CorkReq = true; + } else { Count = min(Count, (int)(NextHeaderPos-GetPos)); } -- cgit v1.2.3