summaryrefslogtreecommitdiff
path: root/recording.c
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2012-09-05 14:16:52 +0200
committerKlaus Schmidinger <vdr@tvdr.de>2012-09-05 14:16:52 +0200
commitf7a1954fe3f64da98c0ee7a638be4e51d5b7b227 (patch)
tree264b85b8d3c8511c8a66cddb5d59c05d56f830a2 /recording.c
parente64ab2a2a7360bc42cdea28b57f77a632cc8ab4e (diff)
downloadvdr-f7a1954fe3f64da98c0ee7a638be4e51d5b7b227.tar.gz
vdr-f7a1954fe3f64da98c0ee7a638be4e51d5b7b227.tar.bz2
Fixed a long delay at the end when replaying a recording that has stopped recording less than an hour ago
Diffstat (limited to 'recording.c')
-rw-r--r--recording.c44
1 files changed, 41 insertions, 3 deletions
diff --git a/recording.c b/recording.c
index ad546f5f..de010440 100644
--- a/recording.c
+++ b/recording.c
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: recording.c 2.58 2012/07/15 10:47:58 kls Exp $
+ * $Id: recording.c 2.59 2012/09/05 11:45:55 kls Exp $
*/
#include "recording.h"
@@ -1607,6 +1607,9 @@ struct tIndexTs {
#define INDEXFILECHECKINTERVAL 500 // ms between checks for existence of the regenerated index file
#define INDEXFILETESTINTERVAL 10 // ms between tests for the size of the index file in case of pausing live video
+cMutex cIndexFile::indexListMutex;
+cVector<const cIndexFile *> cIndexFile::indexList;
+
cIndexFile::cIndexFile(const char *FileName, bool Record, bool IsPesRecording, bool PauseLive)
:resumeFile(FileName, IsPesRecording)
{
@@ -1687,10 +1690,13 @@ cIndexFile::cIndexFile(const char *FileName, bool Record, bool IsPesRecording, b
LOG_ERROR_STR(*fileName);
}
}
+ if (Record)
+ AddToIndexList(this);
}
cIndexFile::~cIndexFile()
{
+ RemoveFromIndexList(this);
if (f >= 0)
close(f);
free(index);
@@ -1735,8 +1741,7 @@ bool cIndexFile::CatchUp(int Index)
for (int i = 0; i <= MAXINDEXCATCHUP && (Index < 0 || Index >= last); i++) {
struct stat buf;
if (fstat(f, &buf) == 0) {
- if (time(NULL) - buf.st_mtime > MININDEXAGE) {
- // apparently the index file is not being written any more
+ if (!IsInIndexList(this)) {
close(f);
f = -1;
break;
@@ -1902,6 +1907,39 @@ int cIndexFile::GetLength(const char *FileName, bool IsPesRecording)
return -1;
}
+void cIndexFile::AddToIndexList(const cIndexFile *IndexFile)
+{
+ cMutexLock MutexLock(&indexListMutex);
+ for (int i = 0; i < indexList.Size(); i++) {
+ if (!indexList[i]) {
+ indexList[i] = IndexFile;
+ return;
+ }
+ }
+ indexList.Append(IndexFile);
+}
+
+void cIndexFile::RemoveFromIndexList(const cIndexFile *IndexFile)
+{
+ cMutexLock MutexLock(&indexListMutex);
+ for (int i = 0; i < indexList.Size(); i++) {
+ if (indexList[i] == IndexFile) {
+ indexList[i] = NULL;
+ return;
+ }
+ }
+}
+
+bool cIndexFile::IsInIndexList(const cIndexFile *IndexFile)
+{
+ cMutexLock MutexLock(&indexListMutex);
+ for (int i = 0; i < indexList.Size(); i++) {
+ if (indexList[i] && !strcmp(indexList[i]->fileName, IndexFile->fileName))
+ return true;
+ }
+ return false;
+}
+
bool GenerateIndex(const char *FileName)
{
if (DirectoryOk(FileName)) {