summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJochen Dolze <vdr@dolze.de>2009-02-06 23:11:28 +0100
committerJochen Dolze <vdr@dolze.de>2009-02-06 23:11:28 +0100
commit7d0c10a7e07a075d464364df7c1e75c444ced316 (patch)
tree2e491e85649bb14f409cd8e7b894422ee4783120
parent210b6ab3d8a5367e116afefe31cea1d83fa094b9 (diff)
downloadvdr-plugin-infosatepg-7d0c10a7e07a075d464364df7c1e75c444ced316.tar.gz
vdr-plugin-infosatepg-7d0c10a7e07a075d464364df7c1e75c444ced316.tar.bz2
Improved processing
-rw-r--r--global.cpp47
-rw-r--r--infosatepg.cpp40
-rw-r--r--infosatepg.h1
-rw-r--r--process.cpp25
4 files changed, 94 insertions, 19 deletions
diff --git a/global.cpp b/global.cpp
index c3ca300..0ba2b8c 100644
--- a/global.cpp
+++ b/global.cpp
@@ -22,7 +22,7 @@ bool cGlobalInfosatdata::NeverSeen(int Day,int Month,int Packetcount)
void cGlobalInfosatdata::Init(char *File,int Day,int Month,int Packetcount)
{
- if (access(file,R_OK)==0)
+ if (access(file,R_OK | W_OK)==0)
{
dsyslog("infosatepg: deleting old %s",file);
unlink(file);
@@ -79,7 +79,17 @@ int cGlobalInfosatdata::Load(int fd)
if (ret!=sizeof (bitfield)) return -1;
ret=read (fd,&file,sizeof (file));
if (ret!=sizeof (file)) return -1;
- if (file[0]!=0) dsyslog ("infosatepg: loaded file=%s",file);
+ // check file
+ if (file[0]!=0)
+ {
+ if (access(file,R_OK | W_OK)==-1)
+ {
+ // file doesnt exist -> receive it again
+ esyslog("infosatepg: cannot access %s",file);
+ Init(file,day,month,pktcnt);
+ }
+ }
+
return ret;
}
@@ -412,6 +422,7 @@ bool cGlobalInfosatepg::FindReceiverChannel()
cChannel *chan;
int source = cSource::FromString("S19.2E"); // only from astra 19.2E
+ // Try to find a channel with the exact frequency
for (int i=0; i<=Channels.MaxNumber(); i++)
{
chan = Channels.GetByNumber(i,0);
@@ -425,6 +436,38 @@ bool cGlobalInfosatepg::FindReceiverChannel()
return true;
}
}
+
+ // None found? Then try to find a channel with frequency + 1
+ for (int i=0; i<=Channels.MaxNumber(); i++)
+ {
+ chan = Channels.GetByNumber(i,0);
+ if (chan)
+ {
+ if (chan->Source()!=source) continue;
+ if (chan->Srate()!=Srate) continue;
+ if (chan->Frequency()!=(Frequency+1)) continue;
+ if (chan->Polarization()!=Polarization) continue;
+ channel=i;
+ return true;
+ }
+ }
+
+ // Still none found? Then try to find a channel with frequency - 1
+ for (int i=0; i<=Channels.MaxNumber(); i++)
+ {
+ chan = Channels.GetByNumber(i,0);
+ if (chan)
+ {
+ if (chan->Source()!=source) continue;
+ if (chan->Srate()!=Srate) continue;
+ if (chan->Frequency()!=(Frequency-1)) continue;
+ if (chan->Polarization()!=Polarization) continue;
+ channel=i;
+ return true;
+ }
+ }
+
+ // No channel available
channel=-1;
return false;
}
diff --git a/infosatepg.cpp b/infosatepg.cpp
index c218bf2..955d0dd 100644
--- a/infosatepg.cpp
+++ b/infosatepg.cpp
@@ -26,6 +26,7 @@ cPluginInfosatepg::cPluginInfosatepg(void)
// VDR OBJECTS TO EXIST OR PRODUCE ANY OUTPUT!
statusMonitor=NULL;
global=new cGlobalInfosatepg;
+ mac=EPG_FIRST_DAY_MAC;
}
cPluginInfosatepg::~cPluginInfosatepg()
@@ -119,24 +120,27 @@ void cPluginInfosatepg::Stop(void)
void cPluginInfosatepg::Housekeeping(void)
{
// Perform any cleanup or other regular tasks.
- for (int mac=EPG_FIRST_DAY_MAC; mac<=EPG_LAST_DAY_MAC; mac++)
+ if (!global->ReceivedAll()) return;
+ if (global->ProcessedAll) return;
+
+ if (!global->Infosatdata[mac].Processed)
{
- if (global->Infosatdata[mac].ReceivedAll() & !global->Infosatdata[mac].Processed)
- {
- isyslog ("infosatepg: janitor found data to be processed: day=%i month=%i",
- global->Infosatdata[mac].Day(),global->Infosatdata[mac].Month());
- cProcessInfosatepg process(mac,global);
- //process.Start();
- }
+ isyslog ("infosatepg: janitor found data to be processed: day=%i month=%i",
+ global->Infosatdata[mac].Day(),global->Infosatdata[mac].Month());
+ cProcessInfosatepg process(mac,global);
}
+ mac++;
+
int numprocessed=0;
- for (int mac=EPG_FIRST_DAY_MAC; mac<=EPG_LAST_DAY_MAC; mac++)
+ for (int pmac=EPG_FIRST_DAY_MAC; pmac<=EPG_LAST_DAY_MAC; pmac++)
{
- if (global->Infosatdata[mac].Processed) numprocessed++;
+ if (global->Infosatdata[pmac].Processed) numprocessed++;
+ }
+ if (numprocessed==EPG_DAYS)
+ {
+ global->ProcessedAll=true;
+ mac=EPG_FIRST_DAY_MAC;
}
- if (numprocessed==EPG_DAYS) global->ProcessedAll=true;
-
-
}
void cPluginInfosatepg::MainThreadHook(void)
@@ -198,6 +202,10 @@ void cPluginInfosatepg::MainThreadHook(void)
cString cPluginInfosatepg::Active(void)
{
// Returns a message string if we are not ready
+
+ // if we cannot receive, we shouldn't wait
+ if (global->Channel()==-1) return NULL;
+
if (!global->ProcessedAll)
return tr("Infosat plugin still working");
@@ -223,7 +231,9 @@ cString cPluginInfosatepg::Active(void)
time_t cPluginInfosatepg::WakeupTime(void)
{
// Returns custom wakeup time for shutdown script
- if (global->NoWakeup) return 0;
+
+ if (global->NoWakeup) return 0; // user option set -> don't wake up
+ if (global->Channel()==-1) return 0; // we cannot receive, so we don't need to wake up
if (global->WakeupTime()==-1) global->SetWakeupTime(300); // just to be safe
time_t Now = time(NULL);
time_t Time = cTimer::SetTime(Now,cTimer::TimeToInt(global->WakeupTime()));
@@ -297,7 +307,7 @@ cString cPluginInfosatepg::SVDRPCommand(const char *Command, const char *Option,
if (global->WakeupTime()!=-1)
{
asprintf(&output,"%s WakeupTime: %04i ", output,global->WakeupTime());
- if (global->NoWakeup) asprintf(&output,"%s (blocked) ",output);
+ if (global->NoWakeup) asprintf(&output,"%s (blocked) ",output);
}
else
{
diff --git a/infosatepg.h b/infosatepg.h
index 6a88e48..e1f51b2 100644
--- a/infosatepg.h
+++ b/infosatepg.h
@@ -20,6 +20,7 @@ private:
// Add any member variables or functions you may need here.
cGlobalInfosatepg *global;
cStatusInfosatepg *statusMonitor;
+ int mac;
public:
cPluginInfosatepg(void);
virtual ~cPluginInfosatepg();
diff --git a/process.cpp b/process.cpp
index bd7fe3c..8d9d6b3 100644
--- a/process.cpp
+++ b/process.cpp
@@ -207,10 +207,19 @@ cProcessInfosatepg::cProcessInfosatepg(int Mac, cGlobalInfosatepg *Global)
}
else
{
- esyslog("infosatepg: failed to get writelock while parsing %s",global->Infosatdata[Mac].GetFile());
+ esyslog("infosatepg: failed to get writelock while parsing %s",file);
}
fclose(f);
}
+ else
+ {
+ if (access(file,R_OK)==-1)
+ {
+ // cannot open file -> receive it again
+ esyslog("infosatepg: cannot access %s",file);
+ global->Infosatdata[Mac].ResetReceivedAll();
+ }
+ }
}
cEvent *cProcessInfosatepg::SearchEvent(cSchedule* Schedule, cInfosatevent *iEvent)
@@ -273,7 +282,7 @@ bool cProcessInfosatepg::AddInfosatEvent(cChannel *channel, cInfosatevent *iEven
}
else
{
- // we are beyond the last event, so just add (if we should)
+ // we are beyond the last event, just add (if we should)
if ((iEvent->Usage() & USE_APPEND)!=USE_APPEND) return true;
Event = new cEvent(iEvent->EventID());
if (!Event) return true;
@@ -431,6 +440,18 @@ bool cProcessInfosatepg::CheckAnnouncement(char *s,cInfosatevent *iEvent)
{
iEvent->SetAnnouncement("Tipp");
}
+ else if ((strlen(s)>=9) && (!strncmp(s,"TAGESTIPP",9)))
+ {
+ iEvent->SetAnnouncement("Tipp");
+ }
+ else if ((strlen(s)>=10) && (!strncmp(s,"Tagestipp!",10)))
+ {
+ iEvent->SetAnnouncement("Tipp");
+ }
+ else if ((strlen(s)>=15) && (!strncmp(s,"CARTOON NETWORK",15)))
+ {
+ // just ignore this
+ }
else ret=false;
return ret;
}