From 3efb79c855c466a777ce65c85d633eb369d251ba Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Sun, 3 Jun 2012 10:03:55 +0200 Subject: Speeded up opening menus on systems with many (several thousands) of recordings, by caching the information whether a recording is stored on the video directory file system within the cRecording data --- CONTRIBUTORS | 2 ++ HISTORY | 5 ++++- recording.c | 19 ++++++++++++++----- recording.h | 4 +++- 4 files changed, 23 insertions(+), 7 deletions(-) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 39b21cd6..baa09ee6 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -2862,6 +2862,8 @@ Torsten Lang for suggesting to make BIDI support check at runtime whether the system runs with UTF-8 for reporting a bug in checking for UTF-8 support in cFont::Bidi() + for a patch that was used to implement caching the information whether a recording + is stored on the video directory file system within the cRecording data Christian Ruppert for some improvements to the Makefiles diff --git a/HISTORY b/HISTORY index 8ec4e410..23412f86 100644 --- a/HISTORY +++ b/HISTORY @@ -7052,7 +7052,7 @@ Video Disk Recorder Revision History - Fixed handling IDLEPRIORITY in cDvbDevice::ProvidesChannel() (thanks to Frank Schmirler). -2012-06-02: Version 1.7.28 +2012-06-03: Version 1.7.28 - Fixed cPixmapMemory::DrawEllipse() for quadrants -1 and -4. - Fixed getting the maximum short channel name length in case there are no short names @@ -7144,3 +7144,6 @@ Video Disk Recorder Revision History Christian Richter). - Added DeleteEvent() to the EPG handler interface, so that an EPG handler can trigger deleting of an event (thanks to Christian Kaiser). +- Speeded up opening menus on systems with many (several thousands) of recordings, by + caching the information whether a recording is stored on the video directory file + system within the cRecording data (based on a patch from Torsten Lang). diff --git a/recording.c b/recording.c index b2ac48e1..2a73645c 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 2.55 2012/06/02 13:52:05 kls Exp $ + * $Id: recording.c 2.56 2012/06/03 09:51:27 kls Exp $ */ #include "recording.h" @@ -153,7 +153,7 @@ void AssertFreeDiskSpace(int Priority, bool Force) cRecording *r = DeletedRecordings.First(); cRecording *r0 = NULL; while (r) { - if (IsOnVideoDirectoryFileSystem(r->FileName())) { // only remove recordings that will actually increase the free video disk space + if (r->IsOnVideoDirectoryFileSystem()) { // only remove recordings that will actually increase the free video disk space if (!r0 || r->Start() < r0->Start()) r0 = r; } @@ -180,7 +180,7 @@ void AssertFreeDiskSpace(int Priority, bool Force) cRecording *r = Recordings.First(); cRecording *r0 = NULL; while (r) { - if (IsOnVideoDirectoryFileSystem(r->FileName())) { // only delete recordings that will actually increase the free video disk space + if (r->IsOnVideoDirectoryFileSystem()) { // only delete recordings that will actually increase the free video disk space if (!r->IsEdited() && r->Lifetime() < MAXLIFETIME) { // edited recordings and recordings with MAXLIFETIME live forever if ((r->Lifetime() == 0 && Priority > r->Priority()) || // the recording has no guaranteed lifetime and the new recording has higher priority (r->Lifetime() > 0 && (time(NULL) - r->Start()) / SECSINDAY >= r->Lifetime())) { // the recording's guaranteed lifetime has expired @@ -617,6 +617,7 @@ cRecording::cRecording(cTimer *Timer, const cEvent *Event) channel = Timer->Channel()->Number(); instanceId = InstanceId; isPesRecording = false; + isOnVideoDirectoryFileSystem = -1; // unknown framesPerSecond = DEFAULTFRAMESPERSECOND; numFrames = -1; deleted = 0; @@ -677,6 +678,7 @@ cRecording::cRecording(const char *FileName) priority = MAXPRIORITY; // assume maximum in case there is no info file lifetime = MAXLIFETIME; isPesRecording = false; + isOnVideoDirectoryFileSystem = -1; // unknown framesPerSecond = DEFAULTFRAMESPERSECOND; numFrames = -1; deleted = 0; @@ -952,6 +954,13 @@ bool cRecording::IsEdited(void) const return *s == '%'; } +bool cRecording::IsOnVideoDirectoryFileSystem(void) const +{ + if (isOnVideoDirectoryFileSystem < 0) + isOnVideoDirectoryFileSystem = ::IsOnVideoDirectoryFileSystem(FileName()); + return isOnVideoDirectoryFileSystem; +} + void cRecording::ReadInfo(void) { info->Read(); @@ -1253,7 +1262,7 @@ int cRecordings::TotalFileSizeMB(void) LOCK_THREAD; for (cRecording *recording = First(); recording; recording = Next(recording)) { int FileSizeMB = recording->FileSizeMB(); - if (FileSizeMB > 0 && IsOnVideoDirectoryFileSystem(recording->FileName())) + if (FileSizeMB > 0 && recording->IsOnVideoDirectoryFileSystem()) size += FileSizeMB; } return size; @@ -1265,7 +1274,7 @@ double cRecordings::MBperMinute(void) int length = 0; LOCK_THREAD; for (cRecording *recording = First(); recording; recording = Next(recording)) { - if (IsOnVideoDirectoryFileSystem(recording->FileName())) { + if (recording->IsOnVideoDirectoryFileSystem()) { int FileSizeMB = recording->FileSizeMB(); if (FileSizeMB > 0) { int LengthInSeconds = recording->LengthInSeconds(); diff --git a/recording.h b/recording.h index 30653b05..56659edc 100644 --- a/recording.h +++ b/recording.h @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: recording.h 2.32 2012/06/02 13:46:55 kls Exp $ + * $Id: recording.h 2.33 2012/06/03 09:49:09 kls Exp $ */ #ifndef __RECORDING_H @@ -91,6 +91,7 @@ private: int channel; int instanceId; bool isPesRecording; + mutable int isOnVideoDirectoryFileSystem; // -1 = unknown, 0 = no, 1 = yes double framesPerSecond; cRecordingInfo *info; cRecording(const cRecording&); // can't copy cRecording @@ -130,6 +131,7 @@ public: bool IsNew(void) const { return GetResume() <= 0; } bool IsEdited(void) const; bool IsPesRecording(void) const { return isPesRecording; } + bool IsOnVideoDirectoryFileSystem(void) const; void ReadInfo(void); bool WriteInfo(void); void SetStartTime(time_t Start); -- cgit v1.2.3