summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--command/demux.cpp15
-rw-r--r--command/markad-standalone.cpp10
-rw-r--r--command/marks.cpp33
-rw-r--r--command/marks.h2
4 files changed, 49 insertions, 11 deletions
diff --git a/command/demux.cpp b/command/demux.cpp
index 73bf110..97fd7d9 100644
--- a/command/demux.cpp
+++ b/command/demux.cpp
@@ -33,6 +33,10 @@ void cMarkAdDemux::Clear()
if (pes2audioes) pes2audioes->Clear();
if (pes2videoes) pes2videoes->Clear();
if (queue) queue->Clear();
+ pause=false;
+ pause_retval=0;
+ min_needed=0;
+ skip=0;
}
void cMarkAdDemux::ProcessVDR(MarkAdPid Pid, uchar *Data, int Count, uchar **Pkt, int *PktLen)
@@ -145,15 +149,20 @@ int cMarkAdDemux::GetMinNeeded(MarkAdPid Pid, uchar *Data, int Count, bool *Offc
if (Offcnt) *Offcnt=true;
return -needed;
}
- if (((Pid.Type==MARKAD_PIDTYPE_AUDIO_AC3) ||
- (Pid.Type==MARKAD_PIDTYPE_AUDIO_MP2)) && (stream!=0xC0))
+ if ((Pid.Type==MARKAD_PIDTYPE_AUDIO_MP2) && (stream!=0xC0))
+ {
+ // ignore 6 header bytes from queue->Put above
+ queue->Clear();
+ if (Offcnt) *Offcnt=true;
+ return -needed;
+ }
+ if ((Pid.Type==MARKAD_PIDTYPE_AUDIO_AC3) && (stream!=0xBD))
{
// ignore 6 header bytes from queue->Put above
queue->Clear();
if (Offcnt) *Offcnt=true;
return -needed;
}
-
return needed+6;
}
else
diff --git a/command/markad-standalone.cpp b/command/markad-standalone.cpp
index c0b7599..adb65f4 100644
--- a/command/markad-standalone.cpp
+++ b/command/markad-standalone.cpp
@@ -419,7 +419,7 @@ void cMarkAdStandalone::AddMark(MarkAdMark *Mark)
}
else
{
- fastexit=true;
+ if (!bGenIndex) fastexit=true;
return;
}
}
@@ -443,7 +443,7 @@ void cMarkAdStandalone::AddMark(MarkAdMark *Mark)
case MT_STOP:
marks.Del(last);
iStop=0;
- fastexit=true;
+ if (!bGenIndex) fastexit=true;
break;
default:
esyslog("please report this! *1");
@@ -473,7 +473,7 @@ void cMarkAdStandalone::AddMark(MarkAdMark *Mark)
case MT_STOP:
marks.DelTill(last->position,false);
iStop=0;
- fastexit=true;
+ if (!bGenIndex) fastexit=true;
break;
default:
esyslog("please report this! *2");
@@ -902,6 +902,7 @@ void cMarkAdStandalone::Reset()
marksAligned=false;
marks.DelAll();
+ marks.CloseIndex(directory,isTS);
memset(&macontext.Video.Info,0,sizeof(macontext.Video.Info));
memset(&macontext.Audio.Info,0,sizeof(macontext.Audio.Info));
@@ -983,12 +984,13 @@ void cMarkAdStandalone::Process(const char *Directory)
if (marks.Save(Directory,macontext.Video.Info.FramesPerSecond,isTS))
{
bool bIndexError=false;
- if (marks.CheckIndex(Directory,isTS,&bIndexError))
+ if (marks.CheckIndex(Directory,isTS,bGenIndex ? framecnt : 0,&bIndexError))
{
if (bIndexError)
{
if (bGenIndex)
{
+ isyslog("index contains errors");
if (RegenerateIndex())
{
isyslog("recreated index");
diff --git a/command/marks.cpp b/command/marks.cpp
index df486c4..529467b 100644
--- a/command/marks.cpp
+++ b/command/marks.cpp
@@ -372,7 +372,7 @@ void clMarks::CloseIndex(const char *Directory, bool isTS)
indexfd=-1;
}
-bool clMarks::CheckIndex(const char *Directory, bool isTS, bool *IndexError)
+bool clMarks::CheckIndex(const char *Directory, bool isTS, int FrameCnt, bool *IndexError)
{
if (!IndexError) return false;
*IndexError=false;
@@ -384,7 +384,34 @@ bool clMarks::CheckIndex(const char *Directory, bool isTS, bool *IndexError)
int fd=open(ipath,O_RDONLY);
free(ipath);
- if (fd==-1) return false;
+ if (fd==-1)
+ {
+ *IndexError=true;
+ return true;
+ }
+
+ if (FrameCnt)
+ {
+ struct stat statbuf;
+ if (fstat(fd,&statbuf)!=-1)
+ {
+ int framecnt;
+ if (isTS)
+ {
+ framecnt=statbuf.st_size/sizeof(struct tIndexTS);
+ }
+ else
+ {
+ framecnt=statbuf.st_size/sizeof(struct tIndexVDR);
+ }
+ if (framecnt!=FrameCnt)
+ {
+ *IndexError=true;
+ close(fd);
+ return true;
+ }
+ }
+ }
clMark *mark=first;
while (mark)
@@ -431,7 +458,7 @@ bool clMarks::CheckIndex(const char *Directory, bool isTS, bool *IndexError)
}
mark=mark->Next();
}
-
+ close(fd);
return true;
}
diff --git a/command/marks.h b/command/marks.h
index 80ba01f..4057fcf 100644
--- a/command/marks.h
+++ b/command/marks.h
@@ -108,7 +108,7 @@ public:
}
bool Backup(const char *Directory, bool isTS);
bool Save(const char *Directory, double FrameRate, bool isTS);
- bool CheckIndex(const char *Directory, bool isTS, bool *IndexError);
+ bool CheckIndex(const char *Directory, bool isTS, int FrameCnt, bool *IndexError);
void WriteIndex(const char *Directory, bool isTS, uint64_t Offset,
int FrameType, int Number);
void CloseIndex(const char *Directory, bool isTS);