diff options
author | Jochen Dolze <vdr@dolze.de> | 2010-03-21 13:12:44 +0100 |
---|---|---|
committer | Jochen Dolze <vdr@dolze.de> | 2010-03-21 13:12:44 +0100 |
commit | 58ce63f95804bdc642c4f39f985763c22e781de3 (patch) | |
tree | 47891e66c0466525b8792b6a7dee6ea7e8dbfd79 | |
parent | 4477718958200c712d9243f8890edd3aece263da (diff) | |
download | vdr-plugin-markad-58ce63f95804bdc642c4f39f985763c22e781de3.tar.gz vdr-plugin-markad-58ce63f95804bdc642c4f39f985763c22e781de3.tar.bz2 |
Checkindex improved again
-rw-r--r-- | markad-standalone.cpp | 41 | ||||
-rw-r--r-- | markad-standalone.h | 5 |
2 files changed, 16 insertions, 30 deletions
diff --git a/markad-standalone.cpp b/markad-standalone.cpp index 26ca9d7..f6b85d6 100644 --- a/markad-standalone.cpp +++ b/markad-standalone.cpp @@ -30,6 +30,7 @@ void syslog_with_tid(int priority, const char *format, ...) vprintf(fmt,ap); va_end(ap); printf("\n"); + fflush(stdout); } } @@ -112,7 +113,7 @@ void cMarkAdStandalone::SaveFrame(int frame) fclose(pFile); } -void cMarkAdStandalone::CheckIndex(bool NoLastFrameCheck) +void cMarkAdStandalone::CheckIndex() { // Here we check the indexfile // if we have an index we check if the @@ -132,16 +133,11 @@ void cMarkAdStandalone::CheckIndex(bool NoLastFrameCheck) if (stat(indexFile,&statbuf)==-1) return; int maxframes=statbuf.st_size/8; - if (NoLastFrameCheck) - { - if (lastmaxframes==maxframes) return; // no new frames still last call! - } - if (maxframes<(framecnt+200)) { - // now we sleep and hopefully the index will grow - dsyslog("we are too fast, waiting %i secs",WAITTIME); - sleep(WAITTIME); + if ((difftime(time(NULL),statbuf.st_mtime))>120) return; // "old" file + sleep(WAITTIME); // now we sleep and hopefully the index will grow + waittime+=WAITTIME; if (errno==EINTR) return; sleepcnt++; if (sleepcnt>=2) @@ -156,10 +152,8 @@ void cMarkAdStandalone::CheckIndex(bool NoLastFrameCheck) sleepcnt=0; notenough=false; } - lastmaxframes=maxframes; } while (notenough); - } bool cMarkAdStandalone::ProcessFile(const char *Directory, int Number) @@ -167,7 +161,7 @@ bool cMarkAdStandalone::ProcessFile(const char *Directory, int Number) if (!Directory) return false; if (!Number) return false; - CheckIndex(true); + CheckIndex(); if (abort) return false; int datalen=385024; @@ -332,7 +326,8 @@ bool cMarkAdStandalone::ProcessFile(const char *Directory, int Number) } } } - CheckIndex(false); + + CheckIndex(); if (abort) { if (f!=-1) close(f); @@ -402,7 +397,7 @@ void cMarkAdStandalone::Process(const char *Directory) } double etime,ftime=0,ptime=0; - etime=sec+((double) usec/1000000); + etime=sec+((double) usec/1000000)-waittime; if (etime>0) ftime=framecnt/etime; if (macontext.Video.Info.FramesPerSecond>0) ptime=ftime/macontext.Video.Info.FramesPerSecond; @@ -691,7 +686,7 @@ cMarkAdStandalone::cMarkAdStandalone(const char *Directory, bool BackupMarks, in noticeVDR_AC3=false; sleepcnt=0; - lastmaxframes=0; + waittime=0; memset(&macontext,0,sizeof(macontext)); macontext.LogoDir=(char *) LogoDir; @@ -895,7 +890,7 @@ int usage() " directory where logos stored, default /var/lib/markad\n" "-p, --priority level=<priority>\n" " priority-level of markad when running in background\n" - " <19...-19> default 19\n" + " <-20...19> default 19\n" "-v, --verbose\n" " increments loglevel by one, can be given multiple times\n" "-B --backupmarks\n" @@ -1336,19 +1331,9 @@ int main(int argc, char *argv[]) // should we renice ? if ( bNice ) { - int niceErr = nice(niceLevel); - int oldErrno = errno; - if ( errno == EPERM || errno == EACCES ) - { - esyslog("ERROR: nice %d: no super-user rights",niceLevel); - errno = oldErrno; - fprintf(stderr, "nice %d: no super-user rights\n",niceLevel); - } - else if ( niceErr != niceLevel ) + if (setpriority(PRIO_PROCESS,0,niceLevel)==-1) { - esyslog("nice ERROR(%d,%d): %m",niceLevel,niceErr); - errno = oldErrno; - fprintf(stderr, "%d %d %m\n",niceErr,errno); + esyslog("failed to set nice to %d",niceLevel); } } diff --git a/markad-standalone.h b/markad-standalone.h index 884a663..99ad0ac 100644 --- a/markad-standalone.h +++ b/markad-standalone.h @@ -17,6 +17,7 @@ #include <signal.h> #include <ctype.h> #include <sys/time.h> +#include <sys/resource.h> #include "demux.h" #include "global.h" @@ -158,6 +159,7 @@ unsigned Descriptor_Length: int lastiframe; int framecnt; bool abort; + int waittime; bool noticeVDR_MP2; bool noticeVDR_AC3; @@ -167,10 +169,9 @@ unsigned Descriptor_Length: bool bIgnoreAudioInfo; bool bIgnoreVideoInfo; - void CheckIndex(bool NoLastFrameCheck); + void CheckIndex(); char *indexFile; int sleepcnt; - int lastmaxframes; void SaveFrame(int Frame); |