how to stop timer?

Message ID 43D11C97.6050103@cadsoft.de
State New
Headers

Commit Message

Klaus Schmidinger Jan. 20, 2006, 5:23 p.m. UTC
  Klaus Schmidinger wrote:
> ...
>> After some more thinking I believe cRecordControls::Start() actually
>> is the better place for this check, since it is called several times.
>>
>> Please try the attached patch.

It just crossed my mind that with the previous modification
it would no longer be possible for a timer with a higher
priority to force deletion of existing recordings with
lower priority. Therefore the attached patch (to be applied
after the previous one) makes sure AssertFreeDiskSpace()
is called before checking for free disk space.

Klaus
  

Patch

--- menu.c	2006/01/20 16:28:18	1.397
+++ menu.c	2006/01/20 17:19:46
@@ -3524,6 +3524,8 @@ 
 {
   static time_t LastNoDiskSpaceMessage = 0;
   int FreeMB = 0;
+  if (Timer)
+     AssertFreeDiskSpace(Timer->Priority(), true);
   VideoDiskSpace(&FreeMB);
   if (FreeMB < MINFREEDISK) {
      if (!Timer || time(NULL) - LastNoDiskSpaceMessage > NODISKSPACEDELTA) {
--- recording.h	2005/12/18 11:26:51	1.48
+++ recording.h	2006/01/20 17:18:28
@@ -21,9 +21,11 @@ 
 extern bool VfatFileSystem;
 
 void RemoveDeletedRecordings(void);
-void AssertFreeDiskSpace(int Priority = 0);
+void AssertFreeDiskSpace(int Priority = 0, bool Force = false);
      ///< The special Priority value -1 means that we shall get rid of any
      ///< deleted recordings faster than normal (because we're cutting).
+     ///< If Force is true, the check will be done even if the timeout
+     ///< hasn't expired yet.
 
 class cResumeFile {
 private:
--- recording.c	2006/01/08 11:40:13	1.132
+++ recording.c	2006/01/20 17:18:59
@@ -117,7 +117,7 @@ 
      }
 }
 
-void AssertFreeDiskSpace(int Priority)
+void AssertFreeDiskSpace(int Priority, bool Force)
 {
   static cMutex Mutex;
   cMutexLock MutexLock(&Mutex);
@@ -126,7 +126,7 @@ 
   // it will get removed during the next call.
   static time_t LastFreeDiskCheck = 0;
   int Factor = (Priority == -1) ? 10 : 1;
-  if (time(NULL) - LastFreeDiskCheck > DISKCHECKDELTA / Factor) {
+  if (Force || time(NULL) - LastFreeDiskCheck > DISKCHECKDELTA / Factor) {
      if (!VideoFileSpaceAvailable(MINDISKSPACE)) {
         // Make sure only one instance of VDR does this:
         cLockFile LockFile(VideoDirectory);