1
0
mirror of https://github.com/VDR4Arch/vdr.git synced 2023-10-10 13:36:52 +02:00

Fixed a possible crash if an editing process is canceled while the edited recording is being replayed

This commit is contained in:
Klaus Schmidinger 2022-11-13 15:23:13 +01:00
parent 982a9a5157
commit 230adc8235
2 changed files with 13 additions and 12 deletions

View File

@ -9780,7 +9780,7 @@ Video Disk Recorder Revision History
out by Onur Sentürk). out by Onur Sentürk).
- Official release. - Official release.
2022-11-06: 2022-11-13:
- Added UPDATE-2.6.0, which was missing in the official 2.6.0 release. - 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 - Fixed unexpected calls of the '-r' script when a recording is interrupted and
@ -9792,3 +9792,5 @@ Video Disk Recorder Revision History
index file is being written, but rather checks for the presence of a '.timer' file. 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 The cutter now writes a dummy '.timer' file with timer ID '0' to make this work
for recordings that are currently being edited. for recordings that are currently being edited.
- Fixed a possible crash if an editing process is canceled while the edited
recording is being replayed.

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: recording.c 5.16 2022/11/13 14:49:08 kls Exp $ * $Id: recording.c 5.17 2022/11/13 15:20:42 kls Exp $
*/ */
#include "recording.h" #include "recording.h"
@ -1889,8 +1889,8 @@ public:
void SetCanceled(void) { usage |= ruCanceled; } void SetCanceled(void) { usage |= ruCanceled; }
const char *FileNameSrc(void) const { return fileNameSrc; } const char *FileNameSrc(void) const { return fileNameSrc; }
const char *FileNameDst(void) const { return fileNameDst; } const char *FileNameDst(void) const { return fileNameDst; }
bool Active(cRecordings *Recordings); bool Active(void);
void Cleanup(cRecordings *Recordings); void Cleanup(void);
}; };
cRecordingsHandlerEntry::cRecordingsHandlerEntry(int Usage, const char *FileNameSrc, const char *FileNameDst) cRecordingsHandlerEntry::cRecordingsHandlerEntry(int Usage, const char *FileNameSrc, const char *FileNameDst)
@ -1921,7 +1921,7 @@ int cRecordingsHandlerEntry::Usage(const char *FileName) const
return u; return u;
} }
bool cRecordingsHandlerEntry::Active(cRecordings *Recordings) bool cRecordingsHandlerEntry::Active(void)
{ {
if ((usage & ruCanceled) != 0) if ((usage & ruCanceled) != 0)
return false; return false;
@ -1941,6 +1941,7 @@ bool cRecordingsHandlerEntry::Active(cRecordings *Recordings)
copier = NULL; copier = NULL;
} }
// Now check if there is something to start: // Now check if there is something to start:
LOCK_RECORDINGS_WRITE;
if ((Usage() & ruPending) != 0) { if ((Usage() & ruPending) != 0) {
if ((Usage() & ruCut) != 0) { if ((Usage() & ruCut) != 0) {
cutter = new cCutter(FileNameSrc()); cutter = new cCutter(FileNameSrc());
@ -1953,7 +1954,6 @@ bool cRecordingsHandlerEntry::Active(cRecordings *Recordings)
copier->Start(); copier->Start();
} }
ClearPending(); ClearPending();
Recordings->SetModified(); // to trigger a state change
return true; return true;
} }
// We're done: // We're done:
@ -1966,12 +1966,11 @@ bool cRecordingsHandlerEntry::Active(cRecordings *Recordings)
Recordings->DelByName(Recording.FileName()); Recordings->DelByName(Recording.FileName());
} }
} }
Recordings->SetModified(); // to trigger a state change
Recordings->TouchUpdate(); Recordings->TouchUpdate();
return false; return false;
} }
void cRecordingsHandlerEntry::Cleanup(cRecordings *Recordings) void cRecordingsHandlerEntry::Cleanup(void)
{ {
if ((usage & ruCut)) { // this was a cut operation... if ((usage & ruCut)) { // this was a cut operation...
if (cutter // ...which had not yet ended... if (cutter // ...which had not yet ended...
@ -1980,6 +1979,7 @@ void cRecordingsHandlerEntry::Cleanup(cRecordings *Recordings)
delete cutter; delete cutter;
cutter = NULL; cutter = NULL;
} }
LOCK_RECORDINGS_WRITE;
cVideoDirectory::RemoveVideoFile(fileNameDst); cVideoDirectory::RemoveVideoFile(fileNameDst);
Recordings->DelByName(fileNameDst); Recordings->DelByName(fileNameDst);
} }
@ -1992,6 +1992,7 @@ void cRecordingsHandlerEntry::Cleanup(cRecordings *Recordings)
delete copier; delete copier;
copier = NULL; copier = NULL;
} }
LOCK_RECORDINGS_WRITE;
cVideoDirectory::RemoveVideoFile(fileNameDst); cVideoDirectory::RemoveVideoFile(fileNameDst);
if ((usage & ruMove) != 0) if ((usage & ruMove) != 0)
Recordings->AddByName(fileNameSrc); Recordings->AddByName(fileNameSrc);
@ -2020,13 +2021,11 @@ void cRecordingsHandler::Action(void)
while (Running()) { while (Running()) {
bool Sleep = false; bool Sleep = false;
{ {
LOCK_RECORDINGS_WRITE;
Recordings->SetExplicitModify();
cMutexLock MutexLock(&mutex); cMutexLock MutexLock(&mutex);
if (cRecordingsHandlerEntry *r = operations.First()) { if (cRecordingsHandlerEntry *r = operations.First()) {
if (!r->Active(Recordings)) { if (!r->Active()) {
error |= r->Error(); error |= r->Error();
r->Cleanup(Recordings); r->Cleanup();
operations.Del(r); operations.Del(r);
} }
else else