diff options
author | Jochen Dolze <vdr@dolze.de> | 2010-03-26 22:34:41 +0100 |
---|---|---|
committer | Jochen Dolze <vdr@dolze.de> | 2010-03-26 22:34:41 +0100 |
commit | b445c3bdbb6b222468052be12ee36422a99a8323 (patch) | |
tree | 77b1ecede26a2d7995b2e744b0eae60724a05096 | |
parent | 80599de74daed049ba6d25cbf2644a8725fc4060 (diff) | |
download | vdr-plugin-markad-b445c3bdbb6b222468052be12ee36422a99a8323.tar.gz vdr-plugin-markad-b445c3bdbb6b222468052be12ee36422a99a8323.tar.bz2 |
Added plugin active check to prevent shutdown while markad is still working
-rw-r--r-- | markad-standalone.cpp | 20 | ||||
-rw-r--r-- | markad.cpp | 4 | ||||
-rw-r--r-- | po/de_DE.po | 5 | ||||
-rw-r--r-- | po/it_IT.po | 6 | ||||
-rw-r--r-- | status.cpp | 105 | ||||
-rw-r--r-- | status.h | 4 |
6 files changed, 128 insertions, 16 deletions
diff --git a/markad-standalone.cpp b/markad-standalone.cpp index 41d2992..6c07bfa 100644 --- a/markad-standalone.cpp +++ b/markad-standalone.cpp @@ -177,11 +177,10 @@ void cMarkAdStandalone::SaveFrame(int frame) void cMarkAdStandalone::CheckIndex(const char *Directory) { - // Here we check the indexfile - // if we have an index we check if the - // index is more advanced than our framecounter - // if not we wait. if we wait too much, - // we discard this check + // Here we check if the index is more + // advanced than our framecounter. + // If not we wait. If we wait too much, + // we discard this check... #define WAITTIME 10 @@ -436,7 +435,8 @@ void cMarkAdStandalone::Process(const char *Directory) } gettimeofday(&tv2,&tz); - long sec,usec; + time_t sec; + suseconds_t usec; sec=tv2.tv_sec-tv1.tv_sec; usec=tv2.tv_usec-tv1.tv_usec; if (usec<0) @@ -757,11 +757,11 @@ bool cMarkAdStandalone::CreatePidfile(const char *Directory) if (oldpid) { // found old pidfile, check if it's still running - long pid; - if (fscanf(oldpid,"%li\n",&pid)==1) + int pid; + if (fscanf(oldpid,"%i\n",&pid)==1) { char procname[256]=""; - snprintf(procname,sizeof(procname),"/proc/%li",pid); + snprintf(procname,sizeof(procname),"/proc/%i",pid); struct stat statbuf; if (stat(procname,&statbuf)!=-1) { @@ -793,7 +793,7 @@ bool cMarkAdStandalone::CreatePidfile(const char *Directory) free(buf); if (!pidfile) return false; - fprintf(pidfile,"%li\n",(long) getpid()); + fprintf(pidfile,"%i\n",(int) getpid()); fflush(pidfile); fclose(pidfile); return true; @@ -123,6 +123,8 @@ void cPluginMarkAd::MainThreadHook(void) cString cPluginMarkAd::Active(void) { // Return a message string if shutdown should be postponed + if (statusMonitor->MarkAdRunning()) + return tr("markad still running"); return NULL; } @@ -170,4 +172,4 @@ cString cPluginMarkAd::SVDRPCommand(const char *UNUSED(Command), const char *UNU } -VDRPLUGINCREATOR(cPluginMarkAd) // Don't touch this!
\ No newline at end of file +VDRPLUGINCREATOR(cPluginMarkAd) // Don't touch this! diff --git a/po/de_DE.po b/po/de_DE.po index 4122191..e3f8891 100644 --- a/po/de_DE.po +++ b/po/de_DE.po @@ -4,7 +4,7 @@ msgid "" msgstr "" "Project-Id-Version: vdr\n" "Report-Msgid-Bugs-To: <see README>\n" -"POT-Creation-Date: 2009-08-27 21:50+0200\n" +"POT-Creation-Date: 2010-03-26 16:28+0100\n" "PO-Revision-Date: 2009-08-27 14:18+0200\n" "Last-Translator: Jochen Dolze <noad@dolze.de>\n" "Language-Team: <vdr@linuxtv.org>\n" @@ -12,5 +12,8 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" +msgid "markad still running" +msgstr "markad läuft noch" + msgid "Mark advertisements" msgstr "Markiere Werbung" diff --git a/po/it_IT.po b/po/it_IT.po index 7a3ee4f..b504784 100644 --- a/po/it_IT.po +++ b/po/it_IT.po @@ -4,7 +4,7 @@ msgid "" msgstr "" "Project-Id-Version: vdr\n" "Report-Msgid-Bugs-To: <see README>\n" -"POT-Creation-Date: 2009-08-27 21:50+0200\n" +"POT-Creation-Date: 2010-03-26 16:28+0100\n" "PO-Revision-Date: 2009-11-14 18:06+0100\n" "Last-Translator: Diego Pierotto <vdr-italian@tiscali.it>\n" "Language-Team: <vdr@linuxtv.org>\n" @@ -15,6 +15,8 @@ msgstr "" "X-Poedit-Country: ITALY\n" "X-Poedit-SourceCharset: utf-8\n" +msgid "markad still running" +msgstr "" + msgid "Mark advertisements" msgstr "Segna i marcatori della pubblicità " - @@ -16,13 +16,25 @@ void cStatusMarkAd::Recording(const cDevice *Device, const char *UNUSED(Name), c if (On) { - // Start the standalone version + // Start markad with (before) recording cString cmd = cString::sprintf("\"%s\"/markad --online=2 -l \"%s\" before \"%s\"",bindir, logodir,FileName); - SystemExec(cmd); + if (SystemExec(cmd)!=-1) + { + Add(FileName); + } } else { +#if 0 + // Start markad after recording + cString cmd = cString::sprintf("\"%s\"/markad -l \"%s\" after \"%s\"",bindir, + logodir,FileName); + if (SystemExec(cmd)!=-1) + { + Add(FileName); + } +#endif // TODO: Start second pass? } @@ -32,4 +44,93 @@ cStatusMarkAd::cStatusMarkAd(const char *BinDir, const char *LogoDir) { bindir=BinDir; logodir=LogoDir; + memset(&recs,0,sizeof(recs)); +} + +cStatusMarkAd::~cStatusMarkAd() +{ + for (int i=0; i<(MAXDEVICES*MAXRECEIVERS); i++) + { + if (recs[i]) free(recs[i]); + } +} + +bool cStatusMarkAd::MarkAdRunning() +{ + bool running=false; + for (int i=0; i<(MAXDEVICES*MAXRECEIVERS); i++) + { + if (recs[i]) + { + char *buf; + if (asprintf(&buf,"%s/markad.pid",recs[i])==-1) + { + // this is crude, but if we fail to allocate memory something + // is going really wrong! + return false; + } + // check for running markad process + FILE *fpid=fopen(buf,"r"); + free(buf); + if (fpid) + { + int pid,ret; + ret=fscanf(fpid,"%i\n",&pid); + fclose(fpid); + if (ret==1) + { + char procname[256]=""; + snprintf(procname,sizeof(procname),"/proc/%i",pid); + struct stat statbuf; + if (stat(procname,&statbuf)==0) + { + // found a running markad + running=true; + } + else + { + if (errno==ENOENT) + { + // no such file or directory -> markad crashed? + // remove filename from list + free(recs[i]); + recs[i]=NULL; + } + else + { + // serious error? -> let vdr close + return false; + } + } + } + } + else + { + if (errno==ENOENT) + { + // no such file or directory -> markad already finished + // remove filename from list + free(recs[i]); + recs[i]=NULL; + } + else + { + // serious error? -> let vdr close + return false; + } + } + } + } + return running; +} + +void cStatusMarkAd::Add(const char *FileName) +{ + for (int i=0; i<(MAXDEVICES*MAXRECEIVERS); i++) + { + if (!recs[i]) + { + recs[i]=strdup(FileName); + } + } } @@ -15,12 +15,16 @@ class cStatusMarkAd : public cStatus { private: + char *recs[MAXDEVICES*MAXRECEIVERS]; const char *bindir; const char *logodir; + void Add(const char *FileName); protected: virtual void Recording(const cDevice *Device, const char *Name, const char *FileName, bool On); public: cStatusMarkAd(const char *BinDir,const char *LogoDir); + ~cStatusMarkAd(); + bool MarkAdRunning(void); }; #endif |