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).
- Official release.
2022-11-06:
2022-11-13:
- 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
@ -9792,3 +9792,5 @@ Video Disk Recorder Revision History
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.
- 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
* 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"
@ -1889,8 +1889,8 @@ public:
void SetCanceled(void) { usage |= ruCanceled; }
const char *FileNameSrc(void) const { return fileNameSrc; }
const char *FileNameDst(void) const { return fileNameDst; }
bool Active(cRecordings *Recordings);
void Cleanup(cRecordings *Recordings);
bool Active(void);
void Cleanup(void);
};
cRecordingsHandlerEntry::cRecordingsHandlerEntry(int Usage, const char *FileNameSrc, const char *FileNameDst)
@ -1921,7 +1921,7 @@ int cRecordingsHandlerEntry::Usage(const char *FileName) const
return u;
}
bool cRecordingsHandlerEntry::Active(cRecordings *Recordings)
bool cRecordingsHandlerEntry::Active(void)
{
if ((usage & ruCanceled) != 0)
return false;
@ -1941,6 +1941,7 @@ bool cRecordingsHandlerEntry::Active(cRecordings *Recordings)
copier = NULL;
}
// Now check if there is something to start:
LOCK_RECORDINGS_WRITE;
if ((Usage() & ruPending) != 0) {
if ((Usage() & ruCut) != 0) {
cutter = new cCutter(FileNameSrc());
@ -1953,7 +1954,6 @@ bool cRecordingsHandlerEntry::Active(cRecordings *Recordings)
copier->Start();
}
ClearPending();
Recordings->SetModified(); // to trigger a state change
return true;
}
// We're done:
@ -1966,12 +1966,11 @@ bool cRecordingsHandlerEntry::Active(cRecordings *Recordings)
Recordings->DelByName(Recording.FileName());
}
}
Recordings->SetModified(); // to trigger a state change
Recordings->TouchUpdate();
return false;
}
void cRecordingsHandlerEntry::Cleanup(cRecordings *Recordings)
void cRecordingsHandlerEntry::Cleanup(void)
{
if ((usage & ruCut)) { // this was a cut operation...
if (cutter // ...which had not yet ended...
@ -1980,6 +1979,7 @@ void cRecordingsHandlerEntry::Cleanup(cRecordings *Recordings)
delete cutter;
cutter = NULL;
}
LOCK_RECORDINGS_WRITE;
cVideoDirectory::RemoveVideoFile(fileNameDst);
Recordings->DelByName(fileNameDst);
}
@ -1992,6 +1992,7 @@ void cRecordingsHandlerEntry::Cleanup(cRecordings *Recordings)
delete copier;
copier = NULL;
}
LOCK_RECORDINGS_WRITE;
cVideoDirectory::RemoveVideoFile(fileNameDst);
if ((usage & ruMove) != 0)
Recordings->AddByName(fileNameSrc);
@ -2020,13 +2021,11 @@ void cRecordingsHandler::Action(void)
while (Running()) {
bool Sleep = false;
{
LOCK_RECORDINGS_WRITE;
Recordings->SetExplicitModify();
cMutexLock MutexLock(&mutex);
if (cRecordingsHandlerEntry *r = operations.First()) {
if (!r->Active(Recordings)) {
if (!r->Active()) {
error |= r->Error();
r->Cleanup(Recordings);
r->Cleanup();
operations.Del(r);
}
else