1
0
mirror of https://github.com/VDR4Arch/vdr.git synced 2023-10-10 13:36:52 +02:00

Modified the EPG scanner to avoid CPU load peaks

This commit is contained in:
Klaus Schmidinger 2003-03-16 13:29:55 +01:00
parent c85272e94d
commit efcb48432d
4 changed files with 34 additions and 37 deletions

View File

@ -549,3 +549,6 @@ Torsten Herz <torsten.herz@web.de>
for fixing a possible deadlock when using the "Blue" button in the "Schedules" menu for fixing a possible deadlock when using the "Blue" button in the "Schedules" menu
to switch to an other channel to switch to an other channel
for reporting a wrong EPG bugfix code number for the MAX_USEFUL_SUBTITLE_LENGTH fix for reporting a wrong EPG bugfix code number for the MAX_USEFUL_SUBTITLE_LENGTH fix
Steffen Becker <stbecker@rbg.informatik.tu-darmstadt.de>
for reporting a problem with CPU load peaks (in the EPG scanner)

View File

@ -1984,3 +1984,5 @@ Video Disk Recorder Revision History
to switch to an other channel (thanks to Torsten Herz). to switch to an other channel (thanks to Torsten Herz).
- Fixed the EPG bugfix code number for the MAX_USEFUL_SUBTITLE_LENGTH fix (thanks to - Fixed the EPG bugfix code number for the MAX_USEFUL_SUBTITLE_LENGTH fix (thanks to
Torsten Herz for reporting this one). Torsten Herz for reporting this one).
- Modified the EPG scanner to avoid CPU load peaks (thanks to Steffen Becker for
reporting this one).

View File

@ -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: eitscan.c 1.11 2003/01/26 16:19:24 kls Exp $ * $Id: eitscan.c 1.12 2003/03/16 13:29:55 kls Exp $
*/ */
#include "eitscan.h" #include "eitscan.h"
@ -16,7 +16,7 @@ cEITScanner::cEITScanner(void)
{ {
lastScan = lastActivity = time(NULL); lastScan = lastActivity = time(NULL);
currentChannel = 0; currentChannel = 0;
lastChannel = 0; memset(lastChannel, 0, sizeof(lastChannel));
numTransponders = 0; numTransponders = 0;
transponders = NULL; transponders = NULL;
} }
@ -51,42 +51,33 @@ void cEITScanner::Process(void)
if (Setup.EPGScanTimeout && Channels.MaxNumber() > 1) { if (Setup.EPGScanTimeout && Channels.MaxNumber() > 1) {
time_t now = time(NULL); time_t now = time(NULL);
if (now - lastScan > ScanTimeout && now - lastActivity > ActivityTimeout) { if (now - lastScan > ScanTimeout && now - lastActivity > ActivityTimeout) {
do { for (int i = 0; i < cDevice::NumDevices(); i++) {
int oldLastChannel = lastChannel; cDevice *Device = cDevice::GetDevice(i);
for (int i = 0; i < cDevice::NumDevices(); i++) { if (Device && Device->CardIndex() < MAXDVBDEVICES) {
cDevice *Device = cDevice::GetDevice(i); if (Device != cDevice::PrimaryDevice() || (cDevice::NumDevices() == 1 && Setup.EPGScanTimeout && now - lastActivity > Setup.EPGScanTimeout * 3600)) {
if (Device && Device->CardIndex() < MAXDVBDEVICES) { if (!(Device->Receiving(true) || Device->Replaying())) {
if (Device != cDevice::PrimaryDevice() || (cDevice::NumDevices() == 1 && Setup.EPGScanTimeout && now - lastActivity > Setup.EPGScanTimeout * 3600)) { for (;;) {
if (!(Device->Receiving(true) || Device->Replaying())) { cChannel *Channel = Channels.GetByNumber(lastChannel[Device->DeviceNumber()] + 1, 1);
int oldCh = lastChannel; if (Channel) {
int ch = oldCh + 1; lastChannel[Device->DeviceNumber()] = Channel->Number();
while (ch != oldCh) { if (Channel->Sid() && Device->ProvidesChannel(Channel) && !TransponderScanned(Channel)) {
if (ch > Channels.MaxNumber()) { if (Device == cDevice::PrimaryDevice() && !currentChannel)
ch = 1; currentChannel = Device->CurrentChannel();
numTransponders = 0; Device->SwitchChannel(Channel, false);
} break;
cChannel *Channel = Channels.GetByNumber(ch, 1); }
if (Channel) { }
if (!Device->ProvidesChannel(Channel)) else {
break; if (lastChannel[Device->DeviceNumber()])
if (Channel->Sid() && !TransponderScanned(Channel)) { numTransponders = 0;
if (Device == cDevice::PrimaryDevice() && !currentChannel) lastChannel[Device->DeviceNumber()] = 0;
currentChannel = Device->CurrentChannel(); break;
Device->SwitchChannel(Channel, false); }
lastChannel = ch; }
break;
}
}
ch = Channel->Number() + 1;
}
}
} }
} }
} }
if (lastChannel != oldLastChannel) }
break;
lastChannel++;
} while (time(NULL) - now < 2);
lastScan = time(NULL); lastScan = time(NULL);
} }
} }

View File

@ -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: eitscan.h 1.1 2002/05/20 11:00:05 kls Exp $ * $Id: eitscan.h 1.2 2003/03/16 13:20:40 kls Exp $
*/ */
#ifndef __EITSCAN_H #ifndef __EITSCAN_H
@ -19,7 +19,8 @@ private:
ScanTimeout = 20 ScanTimeout = 20
}; };
time_t lastScan, lastActivity; time_t lastScan, lastActivity;
int currentChannel, lastChannel; int currentChannel;
int lastChannel[MAXDEVICES];
int numTransponders, *transponders; int numTransponders, *transponders;
bool TransponderScanned(cChannel *Channel); bool TransponderScanned(cChannel *Channel);
public: public: