Mailing List archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[vdr] Re: Speed of VDR 1.3.12 recording menu



On Sun, 26 Sep 2004 13:01:00 +0200, Karsten Müller <kmu@ratio.de> wrote:

> Well, I'd be interested :-)

Enjoy,
Emil

--- recording.c.org	2004-09-25 17:22:06.000000000 +0200
+++ recording.c	2004-09-26 13:26:42.000000000 +0200
@@ -62,6 +62,7 @@
 
 void RemoveDeletedRecordings(void)
 {
+#ifdef SERVER
   static time_t LastRemoveCheck = 0;
   if (time(NULL) - LastRemoveCheck > REMOVECHECKDELTA) {
      // Make sure only one instance of VDR does this:
@@ -87,6 +88,7 @@
         }
      LastRemoveCheck = time(NULL);
      }
+#endif
 }
 
 void AssertFreeDiskSpace(int Priority)
@@ -624,11 +641,26 @@
 {
   deleted = Deleted;
   lastUpdate = 0;
+  starttime = 0;
+  dir = NULL;
 }
 
-void cRecordings::ScanVideoDir(const char *DirName)
+void cRecordings::ScanVideoDir(const char *DirName, int level, bool Incremental)
 {
-  DIR *d = opendir(DirName);
+  DIR *d;
+
+  if (dir != NULL) {
+     if (level != 0)
+        d = opendir(DirName);
+     else
+        d = dir;
+  }
+  else {
+     if (Incremental)
+        d = dir = opendir(DirName);
+     else
+        d = opendir(DirName);
+  }
   if (d) {
      struct dirent *e;
      while ((e = readdir(d)) != NULL) {
@@ -650,33 +682,50 @@
                  if (S_ISDIR(st.st_mode)) {
                     if (endswith(buffer, deleted ? DELEXT : RECEXT)) {
                        cRecording *r = new cRecording(buffer);
-                       if (r->Name())
+                       if (r->Name())  {
                           Add(r);
+			  r->IsNew();
+                       }
                        else
                           delete r;
                        }
-                    else
-                       ScanVideoDir(buffer);
+#ifdef nodef
+                    else if (endswith(buffer, !deleted ? DELEXT : RECEXT))  {
+                       if (Incremental && (time(NULL) - starttime)) return;
+		       continue;
+                    }
+#endif
+		    else  {
+  		       level++;
+                       ScanVideoDir(buffer, level, false);
+                       level--;
+                       }
                     }
                  }
               free(buffer);
               }
+
+              if (Incremental && (time(NULL) - starttime)) return;
            }
      closedir(d);
+     if (level == 0)  dir = NULL;
      }
 }
 
 bool cRecordings::NeedsUpdate(void)
 {
-  return lastUpdate <= LastModifiedTime(AddDirectory(VideoDirectory, ".update"));
+  return (lastUpdate <= LastModifiedTime(AddDirectory(VideoDirectory, ".update")) || dir != NULL);
 }
 
-bool cRecordings::Load(void)
+bool cRecordings::Load(bool Incremental)
 {
-  lastUpdate = time(NULL); // doing this first to make sure we don't miss anything
-  Clear();
-  ScanVideoDir(VideoDirectory);
-  Sort();
+  if (dir == NULL) {
+     lastUpdate = time(NULL); // doing this first to make sure we don't miss anything
+     Clear();
+  }
+  starttime = time(NULL);
+  ScanVideoDir(VideoDirectory, 0, Incremental);
+  if (dir == NULL) Sort();
   return Count() > 0;
 }
 
--- menu.c.org	2004-09-26 12:20:06.000000000 +0200
+++ menu.c	2004-09-26 12:20:45.000000000 +0200
@@ -1417,6 +1417,7 @@
 {
   base = Base ? strdup(Base) : NULL;
   level = Setup.RecordingDirs ? Level : -1;
+  if (Recordings.NeedsUpdate()) Recordings.Load(false);
   Display(); // this keeps the higher level menus from showing up briefly when pressing 'Back' during replay
   const char *LastReplayed = cReplayControl::LastReplayed();
   cMenuRecordingItem *LastItem = NULL;
--- recording.h.org	2004-09-26 09:52:33.000000000 +0200
+++ recording.h	2004-09-26 13:01:12.000000000 +0200
@@ -11,6 +11,7 @@
 #define __RECORDING_H
 
 #include <time.h>
+#include <dirent.h>
 #include "config.h"
 #include "thread.h"
 #include "timers.h"
@@ -72,10 +73,12 @@
 private:
   bool deleted;
   time_t lastUpdate;
-  void ScanVideoDir(const char *DirName);
+  time_t starttime;
+  DIR    *dir;
+  void ScanVideoDir(const char *DirName, int level, bool Incremental = false);
 public:
   cRecordings(bool Deleted = false);
-  bool Load(void);
+  bool Load(bool Incremental = false);
   void TriggerUpdate(void) { lastUpdate = 0; }
   bool NeedsUpdate(void);
   cRecording *GetByName(const char *FileName);
--- vdr.c.org	2004-09-26 13:31:52.000000000 +0200
+++ vdr.c	2004-09-26 10:40:17.000000000 +0200
@@ -477,7 +477,7 @@
 
   // Recordings:
 
-  Recordings.Load();
+  Recordings.Load(true);
 
   // Signal handlers:
 
@@ -611,7 +611,7 @@
                }
            }
         if (!Menu && Recordings.NeedsUpdate())
-           Recordings.Load();
+           Recordings.Load(true);
         // CAM control:
         if (!Menu && !cOsd::IsOpen())
            Menu = CamControl();





Home | Main Index | Thread Index