vdr/eitscan.c
Klaus Schmidinger b60eda5a8e Version 1.1.26
- Removed signal handling and usleep(5000) from cDvbOsd::Cmd() (apparently this
  is no longer necessary with DVB driver 1.0.0pre2 or later).
- If the primary device (as defined in setup.conf) doesn't have an MPEG decoder
  (and thus can't be used as a primary device) VDR now scans all devices at
  startup and uses the first one (if any) that actually has an MPEG decoder.
  That way this will also work automatically if the primary device is implemented
  by a plugin.
- Fixed a possible deadlock when using the "Blue" button in the "Schedules" menu
  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
  Torsten Herz for reporting this one).
- Modified the EPG scanner to avoid CPU load peaks (thanks to Steffen Becker for
  reporting this one).
- Fixed support for Viaccess CAMs (thanks to Axel Gruber for helping to debug this).
2003-03-19 18:00:00 +01:00

85 lines
2.7 KiB
C

/*
* eitscan.c: EIT scanner
*
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
* $Id: eitscan.c 1.12 2003/03/16 13:29:55 kls Exp $
*/
#include "eitscan.h"
#include <stdlib.h>
#include "channels.h"
#include "dvbdevice.h"
cEITScanner::cEITScanner(void)
{
lastScan = lastActivity = time(NULL);
currentChannel = 0;
memset(lastChannel, 0, sizeof(lastChannel));
numTransponders = 0;
transponders = NULL;
}
cEITScanner::~cEITScanner()
{
free(transponders);
}
bool cEITScanner::TransponderScanned(cChannel *Channel)
{
for (int i = 0; i < numTransponders; i++) {
if (transponders[i] == Channel->Frequency())
return true;
}
transponders = (int *)realloc(transponders, ++numTransponders * sizeof(int));
transponders[numTransponders - 1] = Channel->Frequency();
return false;
}
void cEITScanner::Activity(void)
{
if (currentChannel) {
Channels.SwitchTo(currentChannel);
currentChannel = 0;
}
lastActivity = time(NULL);
}
void cEITScanner::Process(void)
{
if (Setup.EPGScanTimeout && Channels.MaxNumber() > 1) {
time_t now = time(NULL);
if (now - lastScan > ScanTimeout && now - lastActivity > ActivityTimeout) {
for (int i = 0; i < cDevice::NumDevices(); i++) {
cDevice *Device = cDevice::GetDevice(i);
if (Device && Device->CardIndex() < MAXDVBDEVICES) {
if (Device != cDevice::PrimaryDevice() || (cDevice::NumDevices() == 1 && Setup.EPGScanTimeout && now - lastActivity > Setup.EPGScanTimeout * 3600)) {
if (!(Device->Receiving(true) || Device->Replaying())) {
for (;;) {
cChannel *Channel = Channels.GetByNumber(lastChannel[Device->DeviceNumber()] + 1, 1);
if (Channel) {
lastChannel[Device->DeviceNumber()] = Channel->Number();
if (Channel->Sid() && Device->ProvidesChannel(Channel) && !TransponderScanned(Channel)) {
if (Device == cDevice::PrimaryDevice() && !currentChannel)
currentChannel = Device->CurrentChannel();
Device->SwitchChannel(Channel, false);
break;
}
}
else {
if (lastChannel[Device->DeviceNumber()])
numTransponders = 0;
lastChannel[Device->DeviceNumber()] = 0;
break;
}
}
}
}
}
}
lastScan = time(NULL);
}
}
}