how to stop timer?

Message ID 200601251643.42446.mhahn@reel-multimedia.com
State New
Headers

Commit Message

Markus Hahn Jan. 25, 2006, 3:43 p.m. UTC
  Am Samstag, 21. Januar 2006 11:05 schrieb Klaus Schmidinger:
> 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.

Hi Klaus, 
because vdr wants  to record out of  EPG, 
I added Timer->ClearFlags(tfActive); 

regards Markus
  

Comments

Klaus Schmidinger Jan. 25, 2006, 4:14 p.m. UTC | #1
Markus Hahn wrote:
> Am Samstag, 21. Januar 2006 11:05 schrieb Klaus Schmidinger:
> 
>>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.
> 
> 
> Hi Klaus, 
> because vdr wants  to record out of  EPG, 

What do you mean by "vdr wants to record out of  EPG"?

> I added Timer->ClearFlags(tfActive); 

I don't think it's a good idea to deactivate a timer.
If this is a repeating timer and the user doesn't realize
that it has been deactivated, it won't record next time.

> ------------------------------------------------------------------------
> 
> diff -x '[A-Z]*' -x '*.bak' -Nu /home/markus/svn-vdr/vdr-current/i18n.c vdr-rbox/i18n.c
> --- /home/markus/svn-vdr/vdr-current/i18n.c	2006-01-12 18:12:18.000000000 +0100
> +++ vdr-rbox/i18n.c	2006-01-24 18:31:33.000000000 +0100
> ...

Your diff doesn't seem to be made against the latest VDR 1.3.40.
It also contained several test outputs.

Klaus
  
Markus Hahn Jan. 25, 2006, 5:28 p.m. UTC | #2
Am Mittwoch, 25. Januar 2006 17:14 schrieb Klaus Schmidinger:
> Markus Hahn wrote:
>>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.
>
> Hi Klaus,
> because vdr wants  to record out of  EPG,

> What do you mean by "vdr wants to record out of  EPG"?

call up EPG -> OK on running programm  -> kRed ->kOk 
will set an instant timer. 
Few minutes later you will get the message
  Skins.Message(mtWarning, tr("Not enough disk space to start recording!")
  or 
  "Low disk space!"
 endlessly. 
  
This is caused by cRecordControl::Process();

regards Markus 















> >
> > diff -x '[A-Z]*' -x '*.bak' -Nu /home/markus/svn-vdr/vdr-current/i18n.c
> > vdr-rbox/i18n.c --- /home/markus/svn-vdr/vdr-current/i18n.c	2006-01-12
> > 18:12:18.000000000 +0100 +++ vdr-rbox/i18n.c	2006-01-24
> > 18:31:33.000000000 +0100
> > ...
>
> Your diff doesn't seem to be made against the latest VDR 1.3.40.
> It also contained several test outputs.
>
> Klaus
>
> _______________________________________________
> vdr mailing list
> vdr@linuxtv.org
> http://www.linuxtv.org/cgi-bin/mailman/listinfo/vdr
  
Klaus Schmidinger Jan. 28, 2006, 1:23 p.m. UTC | #3
Markus Hahn wrote:
> Am Mittwoch, 25. Januar 2006 17:14 schrieb Klaus Schmidinger:
> 
>>Markus Hahn wrote:
>>
>>>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.
>>
>>Hi Klaus,
>>because vdr wants  to record out of  EPG,
> 
> 
>>What do you mean by "vdr wants to record out of  EPG"?
> 
> 
> call up EPG -> OK on running programm  -> kRed ->kOk 
> will set an instant timer. 
> Few minutes later you will get the message
>   Skins.Message(mtWarning, tr("Not enough disk space to start recording!")
>   or 
>   "Low disk space!"
>  endlessly. 
>   
> This is caused by cRecordControl::Process();

When I simulate a full disk by doing

   VideoDiskSpace(&FreeMB);
   FreeMB = 0;//XXX
   if (FreeMB < MINFREEDISK) {

in cRecordControls::Start(), then go into the EPG and program a timer
as you suggested, I immediately get the message

   Not enough disk space to start recording...

and no recording is started. This message is repeated every five minutes,
which I guess is ok since if there actually is somebody watching TV at
that time, they probably want to do something about this. You could
increase NODISKSPACEDELTA if you want this message to be displayed less
often.

If there is enough free disk space at the time the timer is programmed,
the recording will start and once the free disk space falls below
MINDISKSPACE the message

   Low disk space!

will be displayed every DISKCHECKDELTA (100) seconds to make the user
aware of the fact that the disk is running full.

Since there are reasonable timeouts between these messages, I'm afraid
I don't see the actual problem. Maybe I didn't have the exact test
case you are running?

Klaus
  
Georg Acher Jan. 28, 2006, 2:54 p.m. UTC | #4
On Sat, Jan 28, 2006 at 02:23:32PM +0100, Klaus Schmidinger wrote:
 
> Since there are reasonable timeouts between these messages, I'm afraid
> I don't see the actual problem. Maybe I didn't have the exact test
> case you are running?

Imagine some PVR boxes just used for watching live-TV... There's no hard disk
installed. So the repeating message may be a bit annoying ;-)
  
Klaus Schmidinger Jan. 28, 2006, 2:57 p.m. UTC | #5
Georg Acher wrote:
> On Sat, Jan 28, 2006 at 02:23:32PM +0100, Klaus Schmidinger wrote:
>  
> 
>>Since there are reasonable timeouts between these messages, I'm afraid
>>I don't see the actual problem. Maybe I didn't have the exact test
>>case you are running?
> 
> 
> Imagine some PVR boxes just used for watching live-TV... There's no hard disk
> installed. So the repeating message may be a bit annoying ;-)

Well, in that case the whole timer/recording feature should
probably be disabled altogether, shouldn't it?

But then again, who would want a PVR without a hard disk ;-)

Klaus
  

Patch

diff -x '[A-Z]*' -x '*.bak' -Nu /home/markus/svn-vdr/vdr-current/i18n.c vdr-rbox/i18n.c
--- /home/markus/svn-vdr/vdr-current/i18n.c	2006-01-12 18:12:18.000000000 +0100
+++ vdr-rbox/i18n.c	2006-01-24 18:31:33.000000000 +0100
@@ -2253,7 +2253,7 @@ 
     "Kan ikke slukke - parameter '-s' ikke angivet!",
   },
   { "Low disk space!",
-    "Platte beinahe voll!",
+    "Kein Speicherplatz",
     "Premalo prostora na disku!",
     "Spazio su disco insufficiente!",
     "Disk bijna vol!",
Gemeinsame Unterverzeichnisse: /home/markus/svn-vdr/vdr-current/libsi und vdr-rbox/libsi.
diff -x '[A-Z]*' -x '*.bak' -Nu /home/markus/svn-vdr/vdr-current/menu.c vdr-rbox/menu.c
--- /home/markus/svn-vdr/vdr-current/menu.c	2006-01-11 19:51:58.000000000 +0100
+++ vdr-rbox/menu.c	2006-01-25 16:32:42.000000000 +0100
@@ -46,6 +46,8 @@ 
 #define MAXWAITFORCAMMENU 4 // seconds to wait for the CAM menu to open
 
 #define CHNUMWIDTH  (numdigits(Channels.MaxNumber()) + 1)
+#define MINFREEDISK       300 // minimum free disk space required to start recording
+#define NODISKSPACEDELTA  300 // seconds between "Not enough disk space to start recording!" messages
 
 cOsdObject *SetupPluginOsdObject = NULL;
 // --- cMenuEditCaItem -------------------------------------------------------
@@ -754,7 +756,8 @@ 
                           if (memcmp(timer, &data, sizeof(data)) != 0) {
                              *timer = data;
                              if (timer->HasFlags(tfActive))
-                                timer->ClrFlags(~tfAll); // allows external programs to mark active timers with values > 0xFFFF and recognize if the user has modified them
+                                timer->ClrFlags(~tfAll); // allows external programs to mark active timers 
+									                              // with values > 0xFFFF and recognize if the user has modified them
                              }
                           if (addIfConfirmed)
                              Timers.Add(timer);
@@ -4166,7 +4169,18 @@ 
 {
   if (!recorder || !timer || !timer->Matches(t))
      return false;
+
   AssertFreeDiskSpace(timer->Priority());
+
+  int FreeMB = 0;
+  VideoDiskSpace(&FreeMB);
+  if (FreeMB < MINFREEDISK) {
+	 timer->ClrFlags(tfActive);
+	 Timers.SetModified();
+	 Skins.Message(mtWarning, tr("Not enough disk space to start recording!"));
+    return false;
+  }
+
   return true;
 }
 
@@ -4176,6 +4190,25 @@ 
 
 bool cRecordControls::Start(cTimer *Timer, bool Pause)
 {
+	
+   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) {
+			Timer->ClrFlags(tfActive);
+			Timers.SetModified();
+         isyslog("not enough disk space to start recording%s%s", Timer ? " timer " : "", Timer ? *Timer->ToDescr() : "");
+         Skins.Message(mtWarning, tr("Not enough disk space to start recording!"));
+         LastNoDiskSpaceMessage = time(NULL);
+      }
+      return false;
+   }
+
+  LastNoDiskSpaceMessage = 0;
   int ch = Timer ? Timer->Channel()->Number() : cDevice::CurrentChannel();
   cChannel *channel = Channels.GetByNumber(ch);
 
@@ -4203,9 +4236,11 @@ 
                }
            }
         }
-     else if (!Timer || (Timer->Priority() >= Setup.PrimaryLimit && !Timer->Pending()))
+     else if (!Timer || (Timer->Priority() >= Setup.PrimaryLimit && !Timer->Pending())) {
         isyslog("no free DVB device to record channel %d!", ch);
+        Skins.Message(mtError, tr("No free DVB device to record!"));
      }
+  }
   else
      esyslog("ERROR: channel %d not defined!", ch);
   return false;
@@ -4300,7 +4335,7 @@ 
 {
   for (int i = 0; i < MAXRECORDCONTROLS; i++) {
       if (RecordControls[i]) {
-         if (!RecordControls[i]->Process(t))
+         if (!RecordControls[i]->Process(t)) 
             DELETENULL(RecordControls[i]);
          }
       }
diff -x '[A-Z]*' -x '*.bak' -Nu /home/markus/svn-vdr/vdr-current/recording.c vdr-rbox/recording.c
--- /home/markus/svn-vdr/vdr-current/recording.c	2005-11-03 15:59:50.000000000 +0100
+++ vdr-rbox/recording.c	2006-01-24 18:56:49.000000000 +0100
@@ -99,14 +99,14 @@ 
      }
 }
 
-void AssertFreeDiskSpace(int Priority)
+void AssertFreeDiskSpace(int Priority, bool Force)
 {
   // With every call to this function we try to actually remove
   // a file, or mark a file for removal ("delete" it), so that
   // 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);
@@ -161,6 +161,7 @@ 
            }
         // Unable to free disk space, but there's nothing we can do about that...
         isyslog("...no old recording found, giving up");
+		  printf("AssertFreeDiskSpace failed \n"); 
         Interface->Confirm(tr("Low disk space!"), 30);
         }
      LastFreeDiskCheck = time(NULL);
Dateien /home/markus/svn-vdr/vdr-current/.recording.c.swp und vdr-rbox/.recording.c.swp sind verschieden.
diff -x '[A-Z]*' -x '*.bak' -Nu /home/markus/svn-vdr/vdr-current/recording.h vdr-rbox/recording.h
--- /home/markus/svn-vdr/vdr-current/recording.h	2005-10-10 13:46:07.000000000 +0200
+++ vdr-rbox/recording.h	2006-01-23 17:44:09.000000000 +0100
@@ -21,7 +21,7 @@ 
 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).
 
Gemeinsame Unterverzeichnisse: /home/markus/svn-vdr/vdr-current/.svn und vdr-rbox/.svn.
Gemeinsame Unterverzeichnisse: /home/markus/svn-vdr/vdr-current/symbols und vdr-rbox/symbols.
diff -x '[A-Z]*' -x '*.bak' -Nu /home/markus/svn-vdr/vdr-current/timers.c vdr-rbox/timers.c
--- /home/markus/svn-vdr/vdr-current/timers.c	2005-10-10 13:46:07.000000000 +0200
+++ vdr-rbox/timers.c	2006-01-25 13:49:23.000000000 +0100
@@ -25,8 +25,10 @@ 
   startTime = stopTime = 0;
   recording = pending = inVpsMargin = false;
   flags = tfNone;
-  if (Instant)
+  if (Instant) {
      SetFlags(tfActive | tfInstant);
+	  printf("SetFlags %d\n",Flags());
+  }
   channel = Channels.GetByNumber(cDevice::CurrentChannel());
   time_t t = time(NULL);
   struct tm tm_r;
Dateien /home/markus/svn-vdr/vdr-current/.timers.c.swp und vdr-rbox/.timers.c.swp sind verschieden.
diff -x '[A-Z]*' -x '*.bak' -Nu /home/markus/svn-vdr/vdr-current/vdr.c vdr-rbox/vdr.c
--- /home/markus/svn-vdr/vdr-current/vdr.c	2006-01-12 18:12:18.000000000 +0100
+++ vdr-rbox/vdr.c	2006-01-24 18:53:02.000000000 +0100
@@ -691,6 +691,8 @@ 
            time_t Now = time(NULL);
            // Process ongoing recordings:
            cRecordControls::Process(Now);
+					//printf("vdr.c: Hier ist der Fehler %d\n",__LINE__);
+					
            // Start new recordings:
            cTimer *Timer = Timers.GetMatch(Now);
            if (Timer) {
@@ -866,8 +868,9 @@ 
                   DELETENULL(Menu);
                   active_function = osUnknown;
                   Temp = NULL;
-                  if (!cRecordControls::PauseLiveVideo())
-                     Skins.Message(mtError, tr("No free DVB device to record!"));
+                  cRecordControls::PauseLiveVideo();
+                  //if (!cRecordControls::PauseLiveVideo())
+                    // Skins.Message(mtError, tr("No free DVB device to record!"));
                   key = kNone; // nobody else needs to see this key
                   }
                break;
@@ -876,9 +879,9 @@ 
                if (!cControl::Control()) {
                   if (cRecordControls::Start())
                      Skins.Message(mtInfo, tr("Recording"));
-                  else
-                     Skins.Message(mtError, tr("Already recording"));
-                  key = kNone; // nobody else needs to see this key
+                  //else
+                  // Skins.Message(mtError, tr("Already recording"));
+                     key = kNone; // nobody else needs to see this key
                   }
                break;
           // Power off:
@@ -920,9 +923,9 @@ 
                             active_function = osUnknown;
                             Temp = NULL;
                             if (cRecordControls::Start())
-                               ;//XXX Skins.Message(mtInfo, tr("Recording"));
-                            else
-                               Skins.Message(mtError, tr("No free DVB device to record!"));
+                               Skins.Message(mtInfo, tr("Recording started"));
+                          //  else
+                          //  Skins.Message(mtError, tr("No free DVB device to record!"));
                             break;
              case osRecordings:
                             DELETENULL(Menu);