From 60b44caf3d419fa6794d6f08c49354b96a516c4b Mon Sep 17 00:00:00 2001 From: schmirl Date: Wed, 30 May 2007 14:20:14 +0000 Subject: [PATCH] cRingBufferLinear::Read() will return 0 either if EOF is encountered or if the buffer is full. We need to check the buffer space to distinguish these two cases (#307). --- remux/extern.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/remux/extern.c b/remux/extern.c index 3c95296..01d4b33 100644 --- a/remux/extern.c +++ b/remux/extern.c @@ -118,7 +118,12 @@ void cTSExt::Action(void) if (FD_ISSET(m_Outpipe, &rfds)) { int result; - if ((result = m_ResultBuffer->Read(m_Outpipe)) == -1) { + //Read returns 0 if buffer full or EOF + bool bufferFull = m_ResultBuffer->Free() <= 0; //Free may be < 0 + while ((result = m_ResultBuffer->Read(m_Outpipe)) == 0 && bufferFull) + dsyslog("streamdev-server: buffer full while reading from externremux"); + + if (result == -1) { if (errno != EINTR) { LOG_ERROR_STR("read failed"); m_Active = false; @@ -149,7 +154,7 @@ cExternRemux::cExternRemux(int VPid, const int *APids, const int *Dpids, const i m_ResultBuffer(new cRingBufferLinear(WRITERBUFSIZE, TS_SIZE * 2)), m_Remux(new cTSExt(m_ResultBuffer)) { - m_ResultBuffer->SetTimeouts(0, 100); + m_ResultBuffer->SetTimeouts(500, 100); } cExternRemux::~cExternRemux()