diff options
-rw-r--r-- | HISTORY | 3 | ||||
-rw-r--r-- | recording.c | 59 |
2 files changed, 47 insertions, 15 deletions
@@ -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. diff --git a/recording.c b/recording.c index 3ab83ecf..b2718c9a 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 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,26 +62,57 @@ 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") { - static time_t LastRemoveCheck = 0; - if (time(NULL) - LastRemoveCheck > REMOVECHECKDELTA) { +} + +void cRemoveDeletedRecordingsThread::Action(void) +{ + // 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) { - // Make sure only one instance of VDR does this: - cLockFile LockFile(VideoDirectory); - if (LockFile.Lock()) { - cRecording *next = DeletedRecordings.Next(r); - r->Remove(); - DeletedRecordings.Del(r); - r = next; - RemoveEmptyVideoDirectories(); - continue; - } + cRecording *next = DeletedRecordings.Next(r); + r->Remove(); + DeletedRecordings.Del(r); + r = next; + 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); } } |