diff options
author | Jochen Dolze <vdr@dolze.de> | 2010-03-22 00:57:51 +0100 |
---|---|---|
committer | Jochen Dolze <vdr@dolze.de> | 2010-03-22 00:57:51 +0100 |
commit | 072a7fa407d109a8c87365bbf2e9c164fbb116fc (patch) | |
tree | 58fa27d27353e1ff8f8e6c76cdb6583081ade321 | |
parent | e221a9a6cdb4afe17f9c26228aa66aada85ef86a (diff) | |
download | vdr-plugin-markad-072a7fa407d109a8c87365bbf2e9c164fbb116fc.tar.gz vdr-plugin-markad-072a7fa407d109a8c87365bbf2e9c164fbb116fc.tar.bz2 |
Another CheckIndex fix ;)
-rw-r--r-- | markad-standalone.cpp | 3 | ||||
-rw-r--r-- | marks.cpp | 47 |
2 files changed, 37 insertions, 13 deletions
diff --git a/markad-standalone.cpp b/markad-standalone.cpp index 0530131..22ce24d 100644 --- a/markad-standalone.cpp +++ b/markad-standalone.cpp @@ -365,6 +365,7 @@ void cMarkAdStandalone::Process(const char *Directory) if (lastiframe) { MarkAdMark tempmark; + tempmark.Type=MT_COMMON; tempmark.Position=lastiframe; char *buf; @@ -389,7 +390,7 @@ void cMarkAdStandalone::Process(const char *Directory) if (marks.Save(Directory,macontext.Video.Info.FramesPerSecond,isTS)) { - bool bIndexError; + bool bIndexError=false; if (marks.CheckIndex(Directory,isTS,&bIndexError)) { if (bIndexError) @@ -213,11 +213,10 @@ char *clMarks::IndexToHMSF(int Index, double FramesPerSecond) bool clMarks::CheckIndex(const char *Directory, bool isTS, bool *IndexError) { if (!IndexError) return false; - if (!first) - { - *IndexError=false; - return true; - } + *IndexError=false; + + if (!first) return true; + char *ipath=NULL; if (asprintf(&ipath,"%s/index%s",Directory,isTS ? "" : ".vdr")==-1) return false; @@ -229,20 +228,44 @@ bool clMarks::CheckIndex(const char *Directory, bool isTS, bool *IndexError) while (mark) { if (isTS) - { + { off_t offset = mark->position * sizeof(struct tIndexTS); - if (lseek(fd,offset,SEEK_SET)!=offset) return true; + if (lseek(fd,offset,SEEK_SET)!=offset) + { + *IndexError=true; + break; + } struct tIndexTS IndexTS; - if (read(fd,&IndexTS,sizeof(IndexTS))!=sizeof(IndexTS)) return true; - if (IndexTS.independent) return false; + if (read(fd,&IndexTS,sizeof(IndexTS))!=sizeof(IndexTS)) + { + *IndexError=true; + break; + } + if (!IndexTS.independent) + { + *IndexError=true; + break; + } } else { off_t offset = mark->position * sizeof(struct tIndexVDR); - if (lseek(fd,offset,SEEK_SET)!=offset) return true; + if (lseek(fd,offset,SEEK_SET)!=offset) + { + *IndexError=true; + break; + } struct tIndexVDR IndexVDR; - if (read(fd,&IndexVDR,sizeof(IndexVDR))!=sizeof(IndexVDR)) return true; - if (IndexVDR.type==1) return false; + if (read(fd,&IndexVDR,sizeof(IndexVDR))!=sizeof(IndexVDR)) + { + *IndexError=true; + break; + } + if (IndexVDR.type!=1) + { + *IndexError=true; + break; + } } mark=mark->Next(); } |