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:
parent
ae403212f7
commit
b004793ef3
@ -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,36 +273,43 @@ cSatipSectionFilterHandler::~cSatipSectionFilterHandler()
|
|||||||
|
|
||||||
void cSatipSectionFilterHandler::SendAll(void)
|
void cSatipSectionFilterHandler::SendAll(void)
|
||||||
{
|
{
|
||||||
while (true) {
|
cMutexLock MutexLock(&mutexM);
|
||||||
// zero polling structures
|
bool retry;
|
||||||
memset(pollFdsM, 0, sizeof(pollFdsM));
|
do {
|
||||||
|
retry = false;
|
||||||
|
|
||||||
// assemble all handlers to poll
|
// zero polling structures
|
||||||
for (unsigned int i = 0; i < eMaxSecFilterCount; ++i) {
|
memset(pollFdsM, 0, sizeof(pollFdsM));
|
||||||
if (filtersM[i] && filtersM[i]->Available() != 0) {
|
|
||||||
pollFdsM[i].fd = filtersM[i]->GetFd();
|
// assemble all handlers to poll
|
||||||
pollFdsM[i].events = POLLOUT;
|
for (unsigned int i = 0; i < eMaxSecFilterCount; ++i) {
|
||||||
}
|
if (filtersM[i] && filtersM[i]->Available() != 0) {
|
||||||
|
pollFdsM[i].fd = filtersM[i]->GetFd();
|
||||||
|
pollFdsM[i].events = POLLOUT;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// anyone ready for writing
|
// anyone ready for writing
|
||||||
if (poll(pollFdsM, eMaxSecFilterCount, eSecFilterSendTimeoutMs) <= 0)
|
if (poll(pollFdsM, eMaxSecFilterCount, eSecFilterSendTimeoutMs) <= 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// send data
|
// send data
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user