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

Removing deleted recordings is now done in a separate thread

This commit is contained in:
Klaus Schmidinger 2005-12-28 12:21:57 +01:00
parent 967d9b0b03
commit fbddcb2fd6
2 changed files with 48 additions and 16 deletions

View File

@ -3963,7 +3963,7 @@ Video Disk Recorder Revision History
commands may now be executed at any time, and the message will be displayed
(no more "pending message").
2005-12-27: Version 1.3.38
2005-12-28: Version 1.3.38
- Fixed handling second audio and Dolby Digital PIDs for encrypted channels
(was broken in version 1.3.37).
@ -4006,3 +4006,4 @@ Video Disk Recorder Revision History
now immediately creates a timer for the selected event and marks it with 'T'.
If the event is already marked with 'T', the "Red" button opens the "Edit
timer" menu for that timer.
- Removing deleted recordings is now done in a separate thread.

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 1.129 2005/12/18 13:38:30 kls Exp $
* $Id: recording.c 1.130 2005/12/28 12:19:16 kls Exp $
*/
#include "recording.h"
@ -62,16 +62,28 @@ bool VfatFileSystem = false;
cRecordings DeletedRecordings(true);
void RemoveDeletedRecordings(void)
// --- cRemoveDeletedRecordingsThread ----------------------------------------
class cRemoveDeletedRecordingsThread : public cThread {
protected:
virtual void Action(void);
public:
cRemoveDeletedRecordingsThread(void);
};
cRemoveDeletedRecordingsThread::cRemoveDeletedRecordingsThread(void)
:cThread("remove deleted recordings")
{
}
void cRemoveDeletedRecordingsThread::Action(void)
{
static time_t LastRemoveCheck = 0;
if (time(NULL) - LastRemoveCheck > REMOVECHECKDELTA) {
cThreadLock DeletedRecordingsLock(&DeletedRecordings);
for (cRecording *r = DeletedRecordings.First(); r; ) {
if (r->deleted && time(NULL) - r->deleted > DELETEDLIFETIME) {
// Make sure only one instance of VDR does this:
cLockFile LockFile(VideoDirectory);
if (LockFile.Lock()) {
cThreadLock DeletedRecordingsLock(&DeletedRecordings);
for (cRecording *r = DeletedRecordings.First(); r; ) {
if (r->deleted && time(NULL) - r->deleted > DELETEDLIFETIME) {
cRecording *next = DeletedRecordings.Next(r);
r->Remove();
DeletedRecordings.Del(r);
@ -79,9 +91,28 @@ void RemoveDeletedRecordings(void)
RemoveEmptyVideoDirectories();
continue;
}
}
r = DeletedRecordings.Next(r);
}
}
}
static cRemoveDeletedRecordingsThread RemoveDeletedRecordingsThread;
// ---
void RemoveDeletedRecordings(void)
{
static time_t LastRemoveCheck = 0;
if (time(NULL) - LastRemoveCheck > REMOVECHECKDELTA) {
if (!RemoveDeletedRecordingsThread.Active()) {
cThreadLock DeletedRecordingsLock(&DeletedRecordings);
for (cRecording *r = DeletedRecordings.First(); r; r = DeletedRecordings.Next(r)) {
if (r->deleted && time(NULL) - r->deleted > DELETEDLIFETIME) {
RemoveDeletedRecordingsThread.Start();
break;
}
}
}
LastRemoveCheck = time(NULL);
}
}