diff options
author | Klaus Schmidinger <kls (at) cadsoft (dot) de> | 2004-06-19 18:00:00 +0200 |
---|---|---|
committer | Klaus Schmidinger <kls (at) cadsoft (dot) de> | 2004-06-19 18:00:00 +0200 |
commit | eb52e3004a829b73ddea535a881a0161ff19fa55 (patch) | |
tree | c4bf0ff08b4755f086dc079a0706267b53e04b32 /recording.c | |
parent | c281d01c089f4c9410a2756d3bcd99a56f702c86 (diff) | |
download | vdr-patch-lnbsharing-eb52e3004a829b73ddea535a881a0161ff19fa55.tar.gz vdr-patch-lnbsharing-eb52e3004a829b73ddea535a881a0161ff19fa55.tar.bz2 |
Version 1.3.11vdr-1.3.11
- In order to avoid problems on NPTL systems, VDR now checks for the presence
of NPTL at program start, and if it is, exits and tells the user to do
'export LD_ASSUME_KERNEL=2.4.1' before starting VDR.
- Revisited the "Fixed missing audio after replaying a DVD" change because it
introduced a sound disturbance when switching between channels on the same
transponder (thanks to Marco Schlüßler).
- In order to avoid problems on UTF-8 systems, VDR now checks for the presence
of UTF-8 at program start, and if it is, exits and tells the user to turn off
UTF-8 before starting VDR (thanks to Ludwig Nussel for pointing out a problem
with systems that are set to use UTF-8). There are also problems in case the
video partition is mounted with "iocharset=utf8" (thanks to Jörg Knitter for
reporting this one).
Please also read the "IMPORTANT NOTES" section in the INSTALL file!
- Some changes to the SPU decoder interface (thanks to Sven Goethel).
- Some improvements in cOsd creation (thanks to some suggestions by Jouni Karvo).
- Fixed calculating the OSD width and height (thanks to Olaf Henkel for reporting
a problem with long event texts in the "Classic VDR" skin).
- Fixed switching channels while an encrypted channel is being recorded, because the
channel was switched if the new channel was on the same transponder and was
a radio channel or an unencrypted channel (thanks to Martin Dauskardt for reporting
this one).
- No longer using the external 'find' command to scan the video directory for
recordings (based on a suggestion by Mirko Dölle).
- The list of recordings is now kept statically in memory to avoid long delays
when opening the "Recordings" menu. As a side effect, external modifications to
the video directory are no longer immediately reflected in the "Recordings" menu.
If a plugin manipulates the video directory in any way, it can call the function
Recordings.TriggerUpdate() to trigger an update of the list of recordings.
If some external tool manipulates the video directory, it can touch the file
'.update' in the video directory to trigger an update of the list of recordings.
- Fixed a memory leak in theme description handling (thanks to Sascha Volkenandt).
- Added cDevice::Flush() to make sure that all data in the video card's buffers
has been processed (thanks to Reinhard Nissl). Currently this is not yet actually
implemented for FF DVB cards.
- Fixed handling the color button texts in cMenuEditStrItem (thanks to Maynard
Cedric for reporting this one).
- Fixed the description of cRingBufferLinear (thanks to Ludwig Nussel for pointing
out this one).
- Fixed cRingBufferLinear::Get() in case the buffer wraps around (thanks to Ludwig
Nussel for reporting this one).
Diffstat (limited to 'recording.c')
-rw-r--r-- | recording.c | 132 |
1 files changed, 97 insertions, 35 deletions
diff --git a/recording.c b/recording.c index 05efc44..cbc916a 100644 --- a/recording.c +++ b/recording.c @@ -4,10 +4,11 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: recording.c 1.87 2004/05/07 14:24:18 kls Exp $ + * $Id: recording.c 1.88 2004/06/13 20:25:19 kls Exp $ */ #include "recording.h" +#include <dirent.h> #include <errno.h> #include <fcntl.h> #include <stdio.h> @@ -25,7 +26,7 @@ #define RECEXT ".rec" #define DELEXT ".del" /* This was the original code, which works fine in a Linux only environment. - Unfortunately, because of windows and its brain dead file system, we have + Unfortunately, because of Windows and its brain dead file system, we have to use a more complicated approach, in order to allow users who have enabled the VFAT compile time option to see their recordings even if they forget to enable VFAT when compiling a new version of VDR... Gee, do I hate Windows. @@ -47,8 +48,6 @@ #define SUMMARYFILESUFFIX "/summary.vdr" #define MARKSFILESUFFIX "/marks.vdr" -#define FINDCMD "cd '%s' && find '%s' -follow -type d -name '%s' 2> /dev/null" - #define MINDISKSPACE 1024 // MB #define DELETEDLIFETIME 1 // hours after which a deleted recording will be actually removed @@ -70,14 +69,14 @@ void RemoveDeletedRecordings(void) if (!LockFile.Lock()) return; // Remove the oldest file that has been "deleted": - cRecordings Recordings; - if (Recordings.Load(true)) { - cRecording *r = Recordings.First(); + cRecordings DeletedRecordings(true); + if (DeletedRecordings.Load()) { + cRecording *r = DeletedRecordings.First(); cRecording *r0 = r; while (r) { if (r->start < r0->start) r0 = r; - r = Recordings.Next(r); + r = DeletedRecordings.Next(r); } if (r0 && time(NULL) - r0->start > DELETEDLIFETIME * 3600) { r0->Remove(); @@ -105,14 +104,14 @@ void AssertFreeDiskSpace(int Priority) return; // Remove the oldest file that has been "deleted": isyslog("low disk space while recording, trying to remove a deleted recording..."); - cRecordings Recordings; - if (Recordings.Load(true)) { - cRecording *r = Recordings.First(); + cRecordings DeletedRecordings(true); + if (DeletedRecordings.Load()) { + cRecording *r = DeletedRecordings.First(); cRecording *r0 = r; while (r) { if (r->start < r0->start) r0 = r; - r = Recordings.Next(r); + r = DeletedRecordings.Next(r); } if (r0 && r0->Remove()) { LastFreeDiskCheck += REMOVELATENCY / Factor; @@ -121,7 +120,7 @@ void AssertFreeDiskSpace(int Priority) } // No "deleted" files to remove, so let's see if we can delete a recording: isyslog("...no deleted recording found, trying to delete an old recording..."); - if (Recordings.Load(false)) { + if (Recordings.Load()) { cRecording *r = Recordings.First(); cRecording *r0 = NULL; while (r) { @@ -138,8 +137,10 @@ void AssertFreeDiskSpace(int Priority) } r = Recordings.Next(r); } - if (r0 && r0->Delete()) + if (r0 && r0->Delete()) { + Recordings.Del(r0); return; + } } // Unable to free disk space, but there's nothing we can do about that... isyslog("...no old recording found, giving up"); @@ -617,30 +618,75 @@ bool cRecording::Remove(void) // --- cRecordings ----------------------------------------------------------- -bool cRecordings::Load(bool Deleted) +cRecordings Recordings; + +cRecordings::cRecordings(bool Deleted) { - Clear(); - bool result = false; - char *cmd = NULL; - asprintf(&cmd, FINDCMD, VideoDirectory, VideoDirectory, Deleted ? "*" DELEXT : "*" RECEXT); - FILE *p = popen(cmd, "r"); - if (p) { - char *s; - while ((s = readline(p)) != NULL) { - cRecording *r = new cRecording(s); - if (r->Name()) - Add(r); - else - delete r; + deleted = Deleted; + lastUpdate = 0; +} + +bool cRecordings::ScanVideoDir(const char *DirName) +{ + DIR *d = opendir(DirName); + if (d) { + struct dirent *e; + while ((e = readdir(d)) != NULL) { + if (strcmp(e->d_name, ".") && strcmp(e->d_name, "..")) { + char *buffer; + asprintf(&buffer, "%s/%s", DirName, e->d_name); + struct stat st; + if (stat(buffer, &st) == 0) { + if (S_ISLNK(st.st_mode)) { + free(buffer); + buffer = ReadLink(buffer); + if (!buffer) + return false; + if (stat(buffer, &st) != 0) { + LOG_ERROR_STR(DirName); + return false; + } + } + if (S_ISDIR(st.st_mode)) { + if (endswith(buffer, deleted ? DELEXT : RECEXT)) { + cRecording *r = new cRecording(buffer); + if (r->Name()) + Add(r); + else + delete r; + } + else if (!ScanVideoDir(buffer)) + return false; + } + } + else { + LOG_ERROR_STR(DirName); + return false; + } + free(buffer); + } } - pclose(p); - Sort(); - result = Count() > 0; + closedir(d); } - else - Skins.Message(mtError, "Error while opening pipe!"); - free(cmd); - return result; + else { + LOG_ERROR_STR(DirName); + return false; + } + return true; +} + +bool cRecordings::NeedsUpdate(void) +{ + return lastUpdate <= LastModifiedTime(AddDirectory(VideoDirectory, ".update")); +} + +bool cRecordings::Load(void) +{ + lastUpdate = time(NULL); // doing this first to make sure we don't miss anything + Clear(); + ScanVideoDir(VideoDirectory); + Sort(); + return Count() > 0; } cRecording *cRecordings::GetByName(const char *FileName) @@ -652,6 +698,22 @@ cRecording *cRecordings::GetByName(const char *FileName) return NULL; } +void cRecordings::AddByName(const char *FileName) +{ + cRecording *recording = GetByName(FileName); + if (!recording) { + recording = new cRecording(FileName); + Add(recording); + } +} + +void cRecordings::DelByName(const char *FileName) +{ + cRecording *recording = GetByName(FileName); + if (recording) + Del(recording); +} + // --- cMark ----------------------------------------------------------------- char *cMark::buffer = NULL; |