summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJochen Dolze <vdr@dolze.de>2009-03-05 22:01:56 +0100
committerJochen Dolze <vdr@dolze.de>2009-03-05 22:01:56 +0100
commit2417d1f3902ee7bfa78ffd6aeb3ea5421a7ac2dd (patch)
tree4ab43f05a7adbe33c811f761366300c079b48273
parent7a79077d12b0cae3db32cffa35101e95ed86c8cc (diff)
downloadvdr-plugin-infosatepg-2417d1f3902ee7bfa78ffd6aeb3ea5421a7ac2dd.tar.gz
vdr-plugin-infosatepg-2417d1f3902ee7bfa78ffd6aeb3ea5421a7ac2dd.tar.bz2
Moved processing into a thread
Small wakeup handling fixes
-rw-r--r--global.cpp4
-rw-r--r--infosatepg.cpp19
-rw-r--r--process.cpp16
-rw-r--r--process.h5
4 files changed, 24 insertions, 20 deletions
diff --git a/global.cpp b/global.cpp
index 1fcd9d0..3cfa0f3 100644
--- a/global.cpp
+++ b/global.cpp
@@ -424,9 +424,9 @@ bool cGlobalInfosatepg::ReceivedAll(int *Day, int *Month)
// New day, but new data is ready only after wakeup-time
time_t Now = time(NULL);
time_t Time;
- if (WakeupTime()==-1) Time=Now+1; // If no wakeup set, just wait
+ if (WakeupTime()==-1) Time=Now+301; // If no wakeup set, just wait
else Time = WakeupTime();
- if (Now>=Time)
+ if (Now>=(Time-300))
{
// new day and new data should be available
ResetReceivedAll();
diff --git a/infosatepg.cpp b/infosatepg.cpp
index e8b1ca0..74f029b 100644
--- a/infosatepg.cpp
+++ b/infosatepg.cpp
@@ -127,14 +127,18 @@ void cPluginInfosatepg::MainThreadHook(void)
// Perform actions in the context of the main program thread.
if (!global->WaitOk()) return;
- if (!global->ProcessedAll())
+ if ((global->Infosatdata[pmac].ReceivedAll()) && (!global->ProcessedAll()))
{
- if ((!global->Infosatdata[pmac].Processed) && global->Infosatdata[pmac].ReceivedAll())
+ if (!global->Infosatdata[pmac].Processed)
{
isyslog ("infosatepg: found data to be processed: day=%i month=%i",
global->Infosatdata[pmac].Day(),global->Infosatdata[pmac].Month());
cProcessInfosatepg process(pmac,global);
- if (global->Infosatdata[pmac].Processed) pmac++;
+ process.Start();
+ }
+ else
+ {
+ pmac++;
}
global->SetWaitTimer();
}
@@ -233,18 +237,11 @@ time_t cPluginInfosatepg::WakeupTime(void)
if (global->WakeupTime()==-1) return 0; // just to be safe
time_t Now = time(NULL);
time_t Time = global->WakeupTime();
- double diff = difftime(Time,Now);
- if (diff<0)
+ if (difftime(Time,Now)<0)
{
// wakeup time is in the past -> add a day
Time = cTimer::IncDay(Time,1);
}
- else
- {
- // wakeup time is in less than 1 hour -> add a day
- if (diff<3600)
- Time = cTimer::IncDay(Time,1);
- }
return Time;
}
diff --git a/process.cpp b/process.cpp
index a0b1fa5..ee168ef 100644
--- a/process.cpp
+++ b/process.cpp
@@ -612,10 +612,16 @@ const char *cInfosatevent::ExtEPG(void)
// --- cProcessInfosatepg
cProcessInfosatepg::cProcessInfosatepg(int Mac, cGlobalInfosatepg *Global)
+ :cThread("infosatepg")
{
+ mac=Mac;
global=Global;
+}
+
+void cProcessInfosatepg::Action()
+{
FILE *f;
- const char *file = global->Infosatdata[Mac].GetFile();
+ const char *file = global->Infosatdata[mac].GetFile();
f=fopen(file,"r");
if (f)
{
@@ -623,7 +629,7 @@ cProcessInfosatepg::cProcessInfosatepg(int Mac, cGlobalInfosatepg *Global)
if (ParseInfosatepg(f,&firststarttime))
{
global->SetWakeupTime(firststarttime);
- global->Infosatdata[Mac].Processed=true;
+ global->Infosatdata[mac].Processed=true;
}
else
{
@@ -637,7 +643,7 @@ cProcessInfosatepg::cProcessInfosatepg(int Mac, cGlobalInfosatepg *Global)
{
// cannot open file -> receive it again
esyslog("infosatepg: cannot access %s",file);
- global->Infosatdata[Mac].ResetReceivedAll();
+ global->Infosatdata[mac].ResetReceivedAll();
}
}
}
@@ -696,11 +702,11 @@ bool cProcessInfosatepg::AddInfosatEvent(cChannel *channel, cInfosatevent *iEven
if (!Event) Event= (cEvent *) SearchEvent(Schedule,iEvent);
if (!Event)
{
- start=iEvent->StartTime();
+ start=iEvent->StartTime();
dsyslog("infosatepg: failed to find event %s [%li (%s)]", iEvent->Title(),start,ctime(&start));
return true; // just bail out with ok
}
- start=Event->StartTime();
+ start=Event->StartTime();
dsyslog("infosatepg: changing event %s [%li]", Event->Title(),start);
// change existing event, prevent EIT EPG to update
diff --git a/process.h b/process.h
index 9a5d88f..b9db5a3 100644
--- a/process.h
+++ b/process.h
@@ -95,10 +95,11 @@ public:
};
// --- cProcessInfosatepg
-class cProcessInfosatepg //: public cThread
+class cProcessInfosatepg : public cThread
{
private:
cGlobalInfosatepg *global;
+ int mac;
bool AddInfosatEvent(cChannel *channel, cInfosatevent *iEvent);
bool CheckOriginal_and_Episode(char **s,cInfosatevent *iEvent,cCharSetConv *conv);
bool CheckAnnouncement(char *s,cInfosatevent *iEvent);
@@ -107,8 +108,8 @@ private:
u_long DoSum(u_long sum, const char *buf, int nBytes);
cEvent *SearchEvent(cSchedule* Schedule, cInfosatevent *iEvent);
public:
- //virtual void Action(); //(int Mac, cGlobalInfosatepg *Global);
cProcessInfosatepg(int Mac, cGlobalInfosatepg *Global);
+ virtual void Action();
};
#endif