summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--command/markad-standalone.cpp22
-rw-r--r--command/marks.cpp20
-rw-r--r--command/marks.h7
3 files changed, 34 insertions, 15 deletions
diff --git a/command/markad-standalone.cpp b/command/markad-standalone.cpp
index 99dc215..3789290 100644
--- a/command/markad-standalone.cpp
+++ b/command/markad-standalone.cpp
@@ -237,6 +237,7 @@ void cMarkAdStandalone::CheckLogoMarks()
void cMarkAdStandalone::CheckLastMark()
{
+ if (marks.Count()<=2) return; // just two marks -> do nothing
clMark *last=marks.GetLast();
if (!last) return;
@@ -984,14 +985,27 @@ void cMarkAdStandalone::Process(const char *Directory)
marks.CloseIndex(Directory,isTS);
if (marks.Save(Directory,macontext.Video.Info.FramesPerSecond,isTS))
{
- bool bIndexError=false;
- if (marks.CheckIndex(Directory,isTS,bGenIndex ? framecnt : 0,&bIndexError))
+ int iIndexError=false;
+ if (marks.CheckIndex(Directory,isTS,bGenIndex ? framecnt : 0,&iIndexError))
{
- if (bIndexError)
+ if (iIndexError)
{
if (bGenIndex)
{
- isyslog("index contains errors");
+ switch (iIndexError)
+ {
+ case IERR_NOTFOUND:
+ isyslog("no index found");
+
+ break;
+ case IERR_TOOSHORT:
+ isyslog("index too short");
+
+ break;
+ default:
+ isyslog("index contains errors");
+ break;
+ }
if (RegenerateIndex())
{
isyslog("recreated index");
diff --git a/command/marks.cpp b/command/marks.cpp
index 529467b..5c9e25e 100644
--- a/command/marks.cpp
+++ b/command/marks.cpp
@@ -372,10 +372,10 @@ void clMarks::CloseIndex(const char *Directory, bool isTS)
indexfd=-1;
}
-bool clMarks::CheckIndex(const char *Directory, bool isTS, int FrameCnt, bool *IndexError)
+bool clMarks::CheckIndex(const char *Directory, bool isTS, int FrameCnt, int *IndexError)
{
if (!IndexError) return false;
- *IndexError=false;
+ *IndexError=0;
if (!first) return true;
@@ -386,7 +386,7 @@ bool clMarks::CheckIndex(const char *Directory, bool isTS, int FrameCnt, bool *I
free(ipath);
if (fd==-1)
{
- *IndexError=true;
+ *IndexError=IERR_NOTFOUND;
return true;
}
@@ -406,7 +406,7 @@ bool clMarks::CheckIndex(const char *Directory, bool isTS, int FrameCnt, bool *I
}
if (framecnt!=FrameCnt)
{
- *IndexError=true;
+ *IndexError=IERR_TOOSHORT;
close(fd);
return true;
}
@@ -421,18 +421,18 @@ bool clMarks::CheckIndex(const char *Directory, bool isTS, int FrameCnt, bool *I
off_t offset = mark->position * sizeof(struct tIndexTS);
if (lseek(fd,offset,SEEK_SET)!=offset)
{
- *IndexError=true;
+ *IndexError=IERR_SEEK;
break;
}
struct tIndexTS IndexTS;
if (read(fd,&IndexTS,sizeof(IndexTS))!=sizeof(IndexTS))
{
- *IndexError=true;
+ *IndexError=IERR_READ;
break;
}
if (!IndexTS.independent)
{
- *IndexError=true;
+ *IndexError=IERR_FRAME;
break;
}
}
@@ -441,18 +441,18 @@ bool clMarks::CheckIndex(const char *Directory, bool isTS, int FrameCnt, bool *I
off_t offset = mark->position * sizeof(struct tIndexVDR);
if (lseek(fd,offset,SEEK_SET)!=offset)
{
- *IndexError=true;
+ *IndexError=IERR_SEEK;
break;
}
struct tIndexVDR IndexVDR;
if (read(fd,&IndexVDR,sizeof(IndexVDR))!=sizeof(IndexVDR))
{
- *IndexError=true;
+ *IndexError=IERR_READ;
break;
}
if (IndexVDR.type!=1)
{
- *IndexError=true;
+ *IndexError=IERR_FRAME;
break;
}
}
diff --git a/command/marks.h b/command/marks.h
index 4057fcf..94ebb91 100644
--- a/command/marks.h
+++ b/command/marks.h
@@ -108,7 +108,12 @@ public:
}
bool Backup(const char *Directory, bool isTS);
bool Save(const char *Directory, double FrameRate, bool isTS);
- bool CheckIndex(const char *Directory, bool isTS, int FrameCnt, bool *IndexError);
+#define IERR_NOTFOUND 1
+#define IERR_TOOSHORT 2
+#define IERR_SEEK 3
+#define IERR_READ 4
+#define IERR_FRAME 5
+ bool CheckIndex(const char *Directory, bool isTS, int FrameCnt, int *IndexError);
void WriteIndex(const char *Directory, bool isTS, uint64_t Offset,
int FrameType, int Number);
void CloseIndex(const char *Directory, bool isTS);