summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CONTRIBUTORS1
-rw-r--r--HISTORY1
-rw-r--r--sections.c24
-rw-r--r--sections.h5
4 files changed, 22 insertions, 9 deletions
diff --git a/CONTRIBUTORS b/CONTRIBUTORS
index 39ac844d..97028964 100644
--- a/CONTRIBUTORS
+++ b/CONTRIBUTORS
@@ -3659,6 +3659,7 @@ Helmut Binder <cco@aon.at>
for avoiding a lengthy lock on the Channels list when starting a recording
for preventing switching devices for pattern timers
for pointing out that cChannel::Transponder(void) is called very often
+ for fixing flushing old data from the section handler
Ulrich Eckhardt <uli@uli-eckhardt.de>
for reporting a problem with shutdown after user inactivity in case a plugin is
diff --git a/HISTORY b/HISTORY
index 2b1a35fa..3b2cb769 100644
--- a/HISTORY
+++ b/HISTORY
@@ -9716,3 +9716,4 @@ Video Disk Recorder Revision History
std::min(), std::max() and std::swap() if available (thanks to Winfried Köhler).
- No longer permanently looping through PMT PIDs, which caused problems with some
SatIP receivers (reported by André Weidemann; with help from Helmut Binder).
+- Fixed flushing old data from the section handler (thanks to Helmut Binder).
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;
}
}
}
diff --git a/sections.h b/sections.h
index 3aa03953..2e9a4490 100644
--- a/sections.h
+++ b/sections.h
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: sections.h 4.1 2020/11/24 21:19:49 kls Exp $
+ * $Id: sections.h 5.1 2021/06/08 15:10:51 kls Exp $
*/
#ifndef __SECTIONS_H
@@ -27,6 +27,9 @@ private:
cDevice *device;
int statusCount;
bool on, waitForLock;
+ bool flush;
+ bool startFilters;
+ cTimeMs flushTimer;
cList<cFilter> filters;
cList<cFilterHandle> filterHandles;
void Add(const cFilterData *FilterData);