mirror of
https://github.com/VDR4Arch/vdr.git
synced 2023-10-10 13:36:52 +02:00
Fixed flushing old data from the section handler
This commit is contained in:
parent
7b1c097958
commit
0f6265a97f
@ -3659,6 +3659,7 @@ Helmut Binder <cco@aon.at>
|
|||||||
for avoiding a lengthy lock on the Channels list when starting a recording
|
for avoiding a lengthy lock on the Channels list when starting a recording
|
||||||
for preventing switching devices for pattern timers
|
for preventing switching devices for pattern timers
|
||||||
for pointing out that cChannel::Transponder(void) is called very often
|
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>
|
Ulrich Eckhardt <uli@uli-eckhardt.de>
|
||||||
for reporting a problem with shutdown after user inactivity in case a plugin is
|
for reporting a problem with shutdown after user inactivity in case a plugin is
|
||||||
|
1
HISTORY
1
HISTORY
@ -9716,3 +9716,4 @@ Video Disk Recorder Revision History
|
|||||||
std::min(), std::max() and std::swap() if available (thanks to Winfried Köhler).
|
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
|
- No longer permanently looping through PMT PIDs, which caused problems with some
|
||||||
SatIP receivers (reported by André Weidemann; with help from Helmut Binder).
|
SatIP receivers (reported by André Weidemann; with help from Helmut Binder).
|
||||||
|
- Fixed flushing old data from the section handler (thanks to Helmut Binder).
|
||||||
|
24
sections.c
24
sections.c
@ -4,7 +4,7 @@
|
|||||||
* See the main source file 'vdr.c' for copyright information and
|
* See the main source file 'vdr.c' for copyright information and
|
||||||
* how to reach the author.
|
* 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"
|
#include "sections.h"
|
||||||
@ -48,6 +48,8 @@ cSectionHandler::cSectionHandler(cDevice *Device)
|
|||||||
statusCount = 0;
|
statusCount = 0;
|
||||||
on = false;
|
on = false;
|
||||||
waitForLock = false;
|
waitForLock = false;
|
||||||
|
flush = false;
|
||||||
|
startFilters = false;
|
||||||
Start();
|
Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -146,13 +148,15 @@ void cSectionHandler::SetStatus(bool On)
|
|||||||
{
|
{
|
||||||
Lock();
|
Lock();
|
||||||
if (on != On) {
|
if (on != On) {
|
||||||
if (!On || device->HasLock()) {
|
if (!On || (device->HasLock() && startFilters)) {
|
||||||
statusCount++;
|
statusCount++;
|
||||||
for (cFilter *fi = filters.First(); fi; fi = filters.Next(fi)) {
|
for (cFilter *fi = filters.First(); fi; fi = filters.Next(fi)) {
|
||||||
fi->SetStatus(false);
|
fi->SetStatus(false);
|
||||||
if (On)
|
if (On)
|
||||||
fi->SetStatus(true);
|
fi->SetStatus(true);
|
||||||
}
|
}
|
||||||
|
if (flush = On)
|
||||||
|
flushTimer.Set();
|
||||||
on = On;
|
on = On;
|
||||||
waitForLock = false;
|
waitForLock = false;
|
||||||
}
|
}
|
||||||
@ -162,13 +166,18 @@ void cSectionHandler::SetStatus(bool On)
|
|||||||
Unlock();
|
Unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define FLUSH_TIME 100 // ms
|
||||||
|
|
||||||
void cSectionHandler::Action(void)
|
void cSectionHandler::Action(void)
|
||||||
{
|
{
|
||||||
while (Running()) {
|
while (Running()) {
|
||||||
|
|
||||||
Lock();
|
Lock();
|
||||||
if (waitForLock)
|
if (waitForLock) {
|
||||||
|
startFilters = true;
|
||||||
SetStatus(true);
|
SetStatus(true);
|
||||||
|
startFilters = false;
|
||||||
|
}
|
||||||
int NumFilters = filterHandles.Count();
|
int NumFilters = filterHandles.Count();
|
||||||
pollfd pfd[NumFilters];
|
pollfd pfd[NumFilters];
|
||||||
for (cFilterHandle *fh = filterHandles.First(); fh; fh = filterHandles.Next(fh)) {
|
for (cFilterHandle *fh = filterHandles.First(); fh; fh = filterHandles.Next(fh)) {
|
||||||
@ -180,10 +189,7 @@ void cSectionHandler::Action(void)
|
|||||||
int oldStatusCount = statusCount;
|
int oldStatusCount = statusCount;
|
||||||
Unlock();
|
Unlock();
|
||||||
|
|
||||||
if (poll(pfd, NumFilters, 1000) > 0) {
|
if (poll(pfd, NumFilters, waitForLock ? 100 : 1000) > 0) {
|
||||||
bool DeviceHasLock = device->HasLock();
|
|
||||||
if (!DeviceHasLock)
|
|
||||||
cCondWait::SleepMs(100);
|
|
||||||
for (int i = 0; i < NumFilters; i++) {
|
for (int i = 0; i < NumFilters; i++) {
|
||||||
if (pfd[i].revents & POLLIN) {
|
if (pfd[i].revents & POLLIN) {
|
||||||
cFilterHandle *fh = NULL;
|
cFilterHandle *fh = NULL;
|
||||||
@ -198,7 +204,7 @@ void cSectionHandler::Action(void)
|
|||||||
// Read section data:
|
// Read section data:
|
||||||
unsigned char buf[4096]; // max. allowed size for any EIT section
|
unsigned char buf[4096]; // max. allowed size for any EIT section
|
||||||
int r = device->ReadFilter(fh->handle, buf, sizeof(buf));
|
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
|
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
|
if (r > 3) { // minimum number of bytes necessary to get section length
|
||||||
int len = (((buf[1] & 0x0F) << 8) | (buf[2] & 0xFF)) + 3;
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* See the main source file 'vdr.c' for copyright information and
|
* See the main source file 'vdr.c' for copyright information and
|
||||||
* how to reach the author.
|
* 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
|
#ifndef __SECTIONS_H
|
||||||
@ -27,6 +27,9 @@ private:
|
|||||||
cDevice *device;
|
cDevice *device;
|
||||||
int statusCount;
|
int statusCount;
|
||||||
bool on, waitForLock;
|
bool on, waitForLock;
|
||||||
|
bool flush;
|
||||||
|
bool startFilters;
|
||||||
|
cTimeMs flushTimer;
|
||||||
cList<cFilter> filters;
|
cList<cFilter> filters;
|
||||||
cList<cFilterHandle> filterHandles;
|
cList<cFilterHandle> filterHandles;
|
||||||
void Add(const cFilterData *FilterData);
|
void Add(const cFilterData *FilterData);
|
||||||
|
Loading…
Reference in New Issue
Block a user