1
0
mirror of https://github.com/rofafor/vdr-plugin-satip.git synced 2023-10-10 13:37:42 +02:00

Cleanup section filter code.

This commit is contained in:
Rolf Ahrenberg 2017-10-01 19:29:39 +03:00
parent 3cc63dadac
commit 0a9bb96dd4

View File

@ -129,7 +129,7 @@ int cSatipSectionFilter::CopyDump(const uint8_t *bufP, uint8_t lenP)
if (tsFeedpM + lenP > eDmxMaxSectionFeedSize) if (tsFeedpM + lenP > eDmxMaxSectionFeedSize)
lenP = (uint8_t)(eDmxMaxSectionFeedSize - tsFeedpM); lenP = (uint8_t)(eDmxMaxSectionFeedSize - tsFeedpM);
if (lenP <= 0) if (lenP == 0)
return 0; return 0;
memcpy(secBufBaseM + tsFeedpM, bufP, lenP); memcpy(secBufBaseM + tsFeedpM, bufP, lenP);
@ -144,7 +144,7 @@ int cSatipSectionFilter::CopyDump(const uint8_t *bufP, uint8_t lenP)
for (n = 0; secBufpM + 2 < limit; ++n) { for (n = 0; secBufpM + 2 < limit; ++n) {
uint16_t seclen = GetLength(secBufM); uint16_t seclen = GetLength(secBufM);
if ((seclen <= 0) || (seclen > eDmxMaxSectionSize) || ((seclen + secBufpM) > limit)) if ((seclen > eDmxMaxSectionSize) || ((seclen + secBufpM) > limit))
return 0; return 0;
secLenM = seclen; secLenM = seclen;
if (pusiSeenM) if (pusiSeenM)
@ -273,7 +273,11 @@ cSatipSectionFilterHandler::~cSatipSectionFilterHandler()
void cSatipSectionFilterHandler::SendAll(void) void cSatipSectionFilterHandler::SendAll(void)
{ {
while (true) { cMutexLock MutexLock(&mutexM);
bool retry;
do {
retry = false;
// zero polling structures // zero polling structures
memset(pollFdsM, 0, sizeof(pollFdsM)); memset(pollFdsM, 0, sizeof(pollFdsM));
@ -293,16 +297,19 @@ void cSatipSectionFilterHandler::SendAll(void)
for (unsigned int i = 0; i < eMaxSecFilterCount; ++i) { for (unsigned int i = 0; i < eMaxSecFilterCount; ++i) {
if (pollFdsM[i].revents & POLLOUT) if (pollFdsM[i].revents & POLLOUT)
filtersM[i]->Send(); filtersM[i]->Send();
if (!retry && filtersM[i] && filtersM[i]->Available() != 0)
retry = true;
} }
} } while (retry);
} }
void cSatipSectionFilterHandler::Action(void) void cSatipSectionFilterHandler::Action(void)
{ {
debug1("%s Entering [device %d]", __PRETTY_FUNCTION__, deviceIndexM); debug1("%s Entering [device %d]", __PRETTY_FUNCTION__, deviceIndexM);
// Do the thread loop // Do the thread loop
uchar *p = NULL;
while (Running()) { while (Running()) {
uchar *p = NULL;
int len = 0; int len = 0;
// Process all pending TS packets // Process all pending TS packets
while ((p = ringBufferM->Get(len)) != NULL) { while ((p = ringBufferM->Get(len)) != NULL) {
@ -330,9 +337,7 @@ void cSatipSectionFilterHandler::Action(void)
} }
// Send demuxed section packets through all filters // Send demuxed section packets through all filters
mutexM.Lock();
SendAll(); SendAll();
mutexM.Unlock();
} }
debug1("%s Exiting [device %d]", __PRETTY_FUNCTION__, deviceIndexM); debug1("%s Exiting [device %d]", __PRETTY_FUNCTION__, deviceIndexM);
} }