diff options
author | Jochen Dolze <vdr@dolze.de> | 2012-06-25 21:17:37 +0200 |
---|---|---|
committer | Jochen Dolze <vdr@dolze.de> | 2012-06-25 21:17:37 +0200 |
commit | 7e4be58b957cac92e5fbb345fc919012b4cb9d32 (patch) | |
tree | 1f6f7147509d5ebf0c863e81db3de98b341ce824 | |
parent | 2688f79af07c3c833d6c49f0e174d7e966660dd2 (diff) | |
download | vdr-plugin-xmltv2vdr-7e4be58b957cac92e5fbb345fc919012b4cb9d32.tar.gz vdr-plugin-xmltv2vdr-7e4be58b957cac92e5fbb345fc919012b4cb9d32.tar.bz2 |
Removed cSchedulesLock from cParse::Process (not needed)
Prevent Timers.DeleteExpired() while in cImport::Process
Added support for epgsearch-enablesearchtimers-v1.0 service
-rw-r--r-- | import.cpp | 14 | ||||
-rw-r--r-- | parse.cpp | 24 | ||||
-rw-r--r-- | source.cpp | 18 | ||||
-rw-r--r-- | source.h | 7 | ||||
-rw-r--r-- | xmltv2vdr.cpp | 36 | ||||
-rw-r--r-- | xmltv2vdr.h | 26 |
6 files changed, 75 insertions, 50 deletions
@@ -1434,6 +1434,8 @@ int cImport::Process(cEPGSource *Source, cEPGExecutor &myExecutor) time_t endoneday=begin+86400; #endif + Timers.IncBeingEdited(); // prevent Timers.DeleteExpired() to execute + cSchedulesLock *schedulesLock=NULL; const cSchedules *schedules=NULL; @@ -1446,6 +1448,7 @@ int cImport::Process(cEPGSource *Source, cEPGExecutor &myExecutor) if (!myExecutor.StillRunning()) { delete schedulesLock; + Timers.DecBeingEdited(); isyslogs(Source,"request to stop from vdr"); return 0; } @@ -1459,6 +1462,7 @@ int cImport::Process(cEPGSource *Source, cEPGExecutor &myExecutor) { esyslogs(Source,"failed to open %s",g->EPGFile()); delete schedulesLock; + Timers.DecBeingEdited(); return 141; } @@ -1472,6 +1476,7 @@ int cImport::Process(cEPGSource *Source, cEPGExecutor &myExecutor) sqlite3_close(db); esyslogs(Source,"out of memory"); delete schedulesLock; + Timers.DecBeingEdited(); return 134; } @@ -1483,6 +1488,7 @@ int cImport::Process(cEPGSource *Source, cEPGExecutor &myExecutor) sqlite3_close(db); free(sql); delete schedulesLock; + Timers.DecBeingEdited(); return 141; } free(sql); @@ -1581,7 +1587,11 @@ int cImport::Process(cEPGSource *Source, cEPGExecutor &myExecutor) #if VDRVERSNUM < 10726 && (!EPGHANDLER) if ((!addevents) && (xevent.StartTime()>endoneday)) continue; #endif - if (PutEvent(Source, db, schedule, event, &xevent, flags)) cnt++; + if (PutEvent(Source, db, schedule, event, &xevent, flags)) + { + schedules->SetModified(schedule); + cnt++; + } } } else @@ -1619,6 +1629,8 @@ int cImport::Process(cEPGSource *Source, cEPGExecutor &myExecutor) sqlite3_finalize(stmt); sqlite3_close(db); delete schedulesLock; + Timers.SetEvents(); + Timers.DecBeingEdited(); return 0; } @@ -694,25 +694,6 @@ int cParse::Process(cEPGExecutor &myExecutor,char *buffer, int bufsize) if (!buffer) return 134; if (!bufsize) return 134; - cSchedulesLock *schedulesLock=NULL; - const cSchedules *schedules=NULL; - - int l=0; - while (l<300) - { - if (schedulesLock) delete schedulesLock; - schedulesLock = new cSchedulesLock(true,200); // wait up to 60 secs for lock! - schedules = cSchedules::Schedules(*schedulesLock); - if (!myExecutor.StillRunning()) - { - delete schedulesLock; - isyslogs(source,"request to stop from vdr"); - return 0; - } - if (schedules) break; - l++; - } - dsyslogs(source,"parsing output"); xmlDocPtr xmltv; @@ -720,7 +701,6 @@ int cParse::Process(cEPGExecutor &myExecutor,char *buffer, int bufsize) if (!xmltv) { esyslogs(source,"failed to parse xmltv"); - delete schedulesLock; return 141; } @@ -729,7 +709,6 @@ int cParse::Process(cEPGExecutor &myExecutor,char *buffer, int bufsize) { esyslogs(source,"no rootnode in xmltv"); xmlFreeDoc(xmltv); - delete schedulesLock; return 141; } @@ -738,7 +717,6 @@ int cParse::Process(cEPGExecutor &myExecutor,char *buffer, int bufsize) { esyslogs(source,"failed to open or create %s",g->EPGFile()); xmlFreeDoc(xmltv); - delete schedulesLock; return 141; } @@ -764,7 +742,6 @@ int cParse::Process(cEPGExecutor &myExecutor,char *buffer, int bufsize) sqlite3_free(errmsg); sqlite3_close(db); xmlFreeDoc(xmltv); - delete schedulesLock; return 141; } @@ -969,7 +946,6 @@ int cParse::Process(cEPGExecutor &myExecutor,char *buffer, int bufsize) sqlite3_close(db); xmlFreeDoc(xmltv); - delete schedulesLock; return 0; } @@ -51,10 +51,10 @@ void cEPGExecutor::Action() esyslog("failed to set ioprio to 3,7"); } - cSVDRPMsg msg; - if (sources->EPGSearchExists()) + cEPGSearch_Client epgsearch; + if (epgsearch.Installed()) { - if (!msg.Send("SETS OFF")) + if (!epgsearch.DisableSearchTimer()) { esyslog("failed to stop epgsearch searchthread"); } @@ -112,13 +112,14 @@ void cEPGExecutor::Action() forceimportsrc=-1; forcedownload=false; - if (sources->EPGSearchExists()) + if (epgsearch.Installed()) { - if (!msg.Send("SETS ON")) + if (!epgsearch.EnableSearchTimer()) { esyslog("failed to start epgsearch searchthread"); } } + } // ------------------------------------------------------------- @@ -806,11 +807,6 @@ void cEPGSource::Add2Log(struct tm *Tm, const char Prefix, const char *Line) // ------------------------------------------------------------- -cEPGSources::cEPGSources() -{ - epgsearchexists=false; -} - bool cEPGSources::Exists(const char* Name) { if (!Name) return false; @@ -915,10 +911,8 @@ bool cEPGSources::MoveEPGSource(cGlobals *Global, int From, int To) return true; } - void cEPGSources::ReadIn(cGlobals *Global, bool Reload) { - epgsearchexists=Global->EPGSearchExists(); if (Reload) Remove(); DIR *dir=opendir(EPGSOURCES); if (!dir) return; @@ -169,10 +169,7 @@ public: class cEPGSources : public cList<cEPGSource> { -private: - bool epgsearchexists; public: - cEPGSources(); void ReadIn(cGlobals *Global, bool Reload=false); bool RunItNow(); time_t NextRunTime(); @@ -182,10 +179,6 @@ public: int GetSourceIdx(const char *Name); void Remove(); bool MoveEPGSource(cGlobals *Global, int From, int To); - bool EPGSearchExists() - { - return epgsearchexists; - } }; class cPluginXmltv2vdr; diff --git a/xmltv2vdr.cpp b/xmltv2vdr.cpp index 9e18ad8..d0cb078 100644 --- a/xmltv2vdr.cpp +++ b/xmltv2vdr.cpp @@ -217,6 +217,41 @@ bool cSVDRPMsg::Send(const char *format, ...) // ------------------------------------------------------------- +cEPGSearch_Client::cEPGSearch_Client() +{ + plugin=cPluginManager::GetPlugin("epgsearch"); +} + +bool cEPGSearch_Client::EnableSearchTimer() +{ + if (!plugin) return false; + Epgsearch_enablesearchtimers_v1_0 serviceData; + serviceData.enable = true; + if (!plugin->Service("Epgsearch-enablesearchtimers-v1.0", (void*) &serviceData)) + { + // SVDRP fallback + cSVDRPMsg msg; + if (!msg.Send("SETS ON")) return false; + } + return true; +} + +bool cEPGSearch_Client::DisableSearchTimer() +{ + if (!plugin) return false; + Epgsearch_enablesearchtimers_v1_0 serviceData; + serviceData.enable = false; + if (!plugin->Service("Epgsearch-enablesearchtimers-v1.0", (void*) &serviceData)) + { + // SVDRP fallback + cSVDRPMsg msg; + if (!msg.Send("SETS OFF")) return false; + } + return true; +} + +// ------------------------------------------------------------- + cGlobals::cGlobals() { confdir=NULL; @@ -231,7 +266,6 @@ cGlobals::cGlobals() epgtimer=NULL; epgseasonepisode=NULL; epall=0; - epgsearchexists=(cPluginManager::GetPlugin("epgsearch")!=NULL); order=strdup(GetDefaultOrder()); imgdelafter=30; diff --git a/xmltv2vdr.h b/xmltv2vdr.h index 3644969..2f8a308 100644 --- a/xmltv2vdr.h +++ b/xmltv2vdr.h @@ -26,6 +26,13 @@ static const char *DESCRIPTION = trNOOP("Imports xmltv epg into vdr"); int ioprio_set(int which, int who, int ioprio); +// Data structure for service "Epgsearch-enablesearchtimers-v1.0" +struct Epgsearch_enablesearchtimers_v1_0 +{ +// in + bool enable; // enable search timer thread? +}; + class cSVDRPMsg { private: @@ -34,6 +41,20 @@ public: bool Send(const char *format, ...); }; +class cEPGSearch_Client +{ +private: + cPlugin *plugin; +public: + cEPGSearch_Client(); + bool Installed() + { + return (plugin!=NULL); + } + bool EnableSearchTimer(); + bool DisableSearchTimer(); +}; + class cEPGTimer : public cThread { private: @@ -160,7 +181,6 @@ private: int epall; int imgdelafter; bool wakeup; - bool epgsearchexists; cEPGMappings epgmappings; cTEXTMappings textmappings; cEPGSources epgsources; @@ -262,10 +282,6 @@ public: { return order; } - bool EPGSearchExists() - { - return epgsearchexists; - } void SetEPAll(int Value) { epall=Value; |