From 630cc496ea18d1f4958e650a60af3bcae61cbfb3 Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Thu, 14 Dec 2017 14:17:35 +0100 Subject: Moved adding the name of the edited recording into the cutting thread, to avoid a problem with locking the Recordings list --- CONTRIBUTORS | 1 + HISTORY | 2 ++ cutter.c | 10 +++++++--- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 7abbcf63..1c6e0c29 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -3291,6 +3291,7 @@ Matthias Senzel for implementing the parameter "OSD/Sorting direction for recordings" for suggesting to stay in the original folder when moving a recording to a different folder + for reporting problem with locking the Recordings list in the cutting process Marek Nazarko for translating OSD texts to the Polish language diff --git a/HISTORY b/HISTORY index c3986740..6b5b2d2f 100644 --- a/HISTORY +++ b/HISTORY @@ -9234,3 +9234,5 @@ Video Disk Recorder Revision History new location of the recording, but rather stays in the original folder (suggested by Matthias Senzel). If the original folder got empty by moving away the last recording it contained, the cursor is moved up until a non empty folder is found. +- Moved adding the name of the edited recording into the cutting thread, to avoid a + problem with locking the Recordings list (reported by Matthias Senzel). diff --git a/cutter.c b/cutter.c index 67dc4ef5..ed924a71 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.3 2017/05/21 09:45:06 kls Exp $ + * $Id: cutter.c 4.4 2017/12/14 14:09:46 kls Exp $ */ #include "cutter.h" @@ -222,6 +222,7 @@ void cMpeg2Fixer::AdjTref(int TrefOffset) class cCuttingThread : public cThread { private: + cString editedVersionName; // we add the edited version's name to Recordings only after the cutting process has successfully started, so we need to store that name here const char *error; bool isPesRecording; double framesPerSecond; @@ -286,6 +287,7 @@ cCuttingThread::cCuttingThread(const char *FromFileName, const char *ToFileName) if (fromMarks.Load(FromFileName, framesPerSecond, isPesRecording) && fromMarks.Count()) { numSequences = fromMarks.GetNumSequences(); if (numSequences > 0) { + editedVersionName = ToFileName; fromFileName = new cFileName(FromFileName, false, true, isPesRecording); toFileName = new cFileName(ToFileName, true, true, isPesRecording); fromIndex = new cIndexFile(FromFileName, false, isPesRecording); @@ -603,6 +605,10 @@ void cCuttingThread::Action(void) toFile = toFileName->Open(); if (!fromFile || !toFile) return; + { + LOCK_RECORDINGS_WRITE; + Recordings->AddByName(editedVersionName, false); + } int LastEndIndex = -1; while (BeginMark && Running()) { // Suspend cutting if we have severe throughput problems: @@ -677,8 +683,6 @@ bool cCutter::Start(void) cRecordingUserCommand::InvokeCommand(RUC_EDITINGRECORDING, editedVersionName, originalVersionName); if (cVideoDirectory::RemoveVideoFile(editedVersionName) && MakeDirs(editedVersionName, true)) { Recording.WriteInfo(editedVersionName); - LOCK_RECORDINGS_WRITE; - Recordings->AddByName(editedVersionName, false); cuttingThread = new cCuttingThread(originalVersionName, editedVersionName); return true; } -- cgit v1.2.3