From c8e4921a0a8e0d743ae36cec3110f41db775601d Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Sun, 6 Nov 2022 11:49:31 +0100 Subject: [PATCH] Now checking for '.timer' file to determine whether a recording is still active --- HISTORY | 6 +++++- cutter.c | 4 +++- recording.c | 14 +++++++++----- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/HISTORY b/HISTORY index 948af28e..9c8289f2 100644 --- a/HISTORY +++ b/HISTORY @@ -9780,7 +9780,7 @@ Video Disk Recorder Revision History out by Onur Sentürk). - Official release. -2022-11-04: +2022-11-06: - Added UPDATE-2.6.0, which was missing in the official 2.6.0 release. - Fixed unexpected calls of the '-r' script when a recording is interrupted and @@ -9788,3 +9788,7 @@ Video Disk Recorder Revision History - Now dropping capabilities after opening terminal. - Now assuming the lock when removing deleted recordings even if the disk is full (reported by Claus Muus). +- When checking whether a recording is still active, VDR no longer checks whether the + index file is being written, but rather checks for the presence of a '.timer' file. + The cutter now writes a dummy '.timer' file with timer ID '0' to make this work + for recordings that are currently being edited. diff --git a/cutter.c b/cutter.c index 8fda9418..e53f78d2 100644 --- a/cutter.c +++ b/cutter.c @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: cutter.c 4.6 2018/01/18 12:19:31 kls Exp $ + * $Id: cutter.c 5.1 2022/11/06 11:25:13 kls Exp $ */ #include "cutter.h" @@ -677,6 +677,7 @@ bool cCutter::Start(void) cRecordingUserCommand::InvokeCommand(RUC_EDITINGRECORDING, editedVersionName, originalVersionName); if (cVideoDirectory::RemoveVideoFile(editedVersionName) && MakeDirs(editedVersionName, true)) { Recording.WriteInfo(editedVersionName); + SetRecordingTimerId(editedVersionName, cString::sprintf("%d@%s", 0, Setup.SVDRPHostName)); cuttingThread = new cCuttingThread(originalVersionName, editedVersionName); return true; } @@ -693,6 +694,7 @@ void cCutter::Stop(void) const char *Error = cuttingThread ? cuttingThread->Error() : NULL; delete cuttingThread; cuttingThread = NULL; + SetRecordingTimerId(editedVersionName, NULL); if ((Interrupted || Error) && *editedVersionName) { if (Interrupted) isyslog("editing process has been interrupted"); diff --git a/recording.c b/recording.c index 0bff62b6..60cfc1b6 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 5.14 2022/01/24 10:44:21 kls Exp $ + * $Id: recording.c 5.15 2022/11/06 11:26:16 kls Exp $ */ #include "recording.h" @@ -66,7 +66,6 @@ #define DISKCHECKDELTA 100 // seconds between checks for free disk space #define REMOVELATENCY 10 // seconds to wait until next check after removing a file #define MARKSUPDATEDELTA 10 // seconds between checks for updating editing marks -#define MININDEXAGE 3600 // seconds before an index file is considered no longer to be written #define MAXREMOVETIME 10 // seconds after which to return from removing deleted recordings #define MAX_LINK_LEVEL 6 @@ -1351,6 +1350,11 @@ int cRecording::IsInUse(void) const return Use; } +static bool StillRecording(const char *Directory) +{ + return access(AddDirectory(Directory, TIMERRECFILE), F_OK) == 0; +} + void cRecording::ResetResume(void) const { resume = RESUME_NOT_INITIALIZED; @@ -1360,7 +1364,7 @@ int cRecording::NumFrames(void) const { if (numFrames < 0) { int nf = cIndexFile::GetLength(FileName(), IsPesRecording()); - if (time(NULL) - LastModifiedTime(cIndexFile::IndexFileName(FileName(), IsPesRecording())) < MININDEXAGE) + if (StillRecording(FileName())) return nf; // check again later for ongoing recordings numFrames = nf; } @@ -1379,7 +1383,7 @@ int cRecording::FileSizeMB(void) const { if (fileSizeMB < 0) { int fs = DirSizeMB(FileName()); - if (time(NULL) - LastModifiedTime(cIndexFile::IndexFileName(FileName(), IsPesRecording())) < MININDEXAGE) + if (StillRecording(FileName())) return fs; // check again later for ongoing recordings fileSizeMB = fs; } @@ -2610,7 +2614,7 @@ cIndexFile::cIndexFile(const char *FileName, bool Record, bool IsPesRecording, b } else if (isPesRecording) ConvertFromPes(index, size); - if (!index || time(NULL) - buf.st_mtime >= MININDEXAGE) { + if (!index || !StillRecording(FileName)) { close(f); f = -1; }