summaryrefslogtreecommitdiff
path: root/sections.c
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2021-06-08 15:10:51 +0200
committerKlaus Schmidinger <vdr@tvdr.de>2021-06-08 15:10:51 +0200
commit0f6265a97fcdfe2b5eb8b46eeac04c63e3379118 (patch)
treea8ee58836b812a82f1ed5d26d509940e3d37bbc1 /sections.c
parent7b1c09795897282cf6bde0e9742814494f6407a1 (diff)
downloadvdr-0f6265a97fcdfe2b5eb8b46eeac04c63e3379118.tar.gz
vdr-0f6265a97fcdfe2b5eb8b46eeac04c63e3379118.tar.bz2
Fixed flushing old data from the section handler
Diffstat (limited to 'sections.c')
-rw-r--r--sections.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/sections.c b/sections.c
index 035096bb..0d7bef34 100644
--- a/sections.c
+++ b/sections.c
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: sections.c 4.2 2020/11/24 21:19:49 kls Exp $
+ * $Id: sections.c 5.1 2021/06/08 15:10:51 kls Exp $
*/
#include "sections.h"
@@ -48,6 +48,8 @@ cSectionHandler::cSectionHandler(cDevice *Device)
statusCount = 0;
on = false;
waitForLock = false;
+ flush = false;
+ startFilters = false;
Start();
}
@@ -146,13 +148,15 @@ void cSectionHandler::SetStatus(bool On)
{
Lock();
if (on != On) {
- if (!On || device->HasLock()) {
+ if (!On || (device->HasLock() && startFilters)) {
statusCount++;
for (cFilter *fi = filters.First(); fi; fi = filters.Next(fi)) {
fi->SetStatus(false);
if (On)
fi->SetStatus(true);
}
+ if (flush = On)
+ flushTimer.Set();
on = On;
waitForLock = false;
}
@@ -162,13 +166,18 @@ void cSectionHandler::SetStatus(bool On)
Unlock();
}
+#define FLUSH_TIME 100 // ms
+
void cSectionHandler::Action(void)
{
while (Running()) {
Lock();
- if (waitForLock)
+ if (waitForLock) {
+ startFilters = true;
SetStatus(true);
+ startFilters = false;
+ }
int NumFilters = filterHandles.Count();
pollfd pfd[NumFilters];
for (cFilterHandle *fh = filterHandles.First(); fh; fh = filterHandles.Next(fh)) {
@@ -180,10 +189,7 @@ void cSectionHandler::Action(void)
int oldStatusCount = statusCount;
Unlock();
- if (poll(pfd, NumFilters, 1000) > 0) {
- bool DeviceHasLock = device->HasLock();
- if (!DeviceHasLock)
- cCondWait::SleepMs(100);
+ if (poll(pfd, NumFilters, waitForLock ? 100 : 1000) > 0) {
for (int i = 0; i < NumFilters; i++) {
if (pfd[i].revents & POLLIN) {
cFilterHandle *fh = NULL;
@@ -198,7 +204,7 @@ void cSectionHandler::Action(void)
// Read section data:
unsigned char buf[4096]; // max. allowed size for any EIT section
int r = device->ReadFilter(fh->handle, buf, sizeof(buf));
- if (!DeviceHasLock)
+ if (flush)
continue; // we do the read anyway, to flush any data that might have come from a different transponder
if (r > 3) { // minimum number of bytes necessary to get section length
int len = (((buf[1] & 0x0F) << 8) | (buf[2] & 0xFF)) + 3;
@@ -217,6 +223,8 @@ void cSectionHandler::Action(void)
}
}
}
+ if (flush)
+ flush = flushTimer.Elapsed() <= FLUSH_TIME;
}
}
}