summaryrefslogtreecommitdiff
path: root/recording.c
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2012-03-13 13:22:06 +0100
committerKlaus Schmidinger <vdr@tvdr.de>2012-03-13 13:22:06 +0100
commit71f02e4f80b2ad6cd265e68c4b2253ae5e1b3663 (patch)
treea27cd27a5264ee5a849607b956ad54c974e3e61c /recording.c
parent845d6f36c16f2409eff161f8005d9dd2a0a4bf50 (diff)
downloadvdr-71f02e4f80b2ad6cd265e68c4b2253ae5e1b3663.tar.gz
vdr-71f02e4f80b2ad6cd265e68c4b2253ae5e1b3663.tar.bz2
When estimating the remaining disk space (in hours), the average data rate of all existing recordings is now taken into account
Diffstat (limited to 'recording.c')
-rw-r--r--recording.c46
1 files changed, 38 insertions, 8 deletions
diff --git a/recording.c b/recording.c
index a4076ed4..e1f7ec96 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.52 2012/03/12 14:49:28 kls Exp $
+ * $Id: recording.c 2.53 2012/03/13 13:17:57 kls Exp $
*/
#include "recording.h"
@@ -1063,6 +1063,17 @@ int cRecording::LengthInSeconds(void) const
return -1;
}
+int cRecording::FileSizeMB(void) const
+{
+ if (fileSizeMB < 0) {
+ int fs = DirSizeMB(FileName());
+ if (time(NULL) - LastModifiedTime(FileName()) < MININDEXAGE)
+ return fs; // check again later for ongoing recordings
+ fileSizeMB = fs;
+ }
+ return fileSizeMB;
+}
+
// --- cRecordings -----------------------------------------------------------
cRecordings Recordings;
@@ -1127,14 +1138,13 @@ void cRecordings::ScanVideoDir(const char *DirName, bool Foreground, int LinkLev
cRecording *r = new cRecording(buffer);
if (r->Name()) {
r->NumFrames(); // initializes the numFrames member
+ r->FileSizeMB(); // initializes the fileSizeMB member
+ if (deleted)
+ r->deleted = time(NULL);
Lock();
Add(r);
ChangeState();
Unlock();
- if (deleted) {
- r->fileSizeMB = DirSizeMB(buffer);
- r->deleted = time(NULL);
- }
}
else
delete r;
@@ -1216,7 +1226,6 @@ void cRecordings::DelByName(const char *FileName)
if (ext) {
strncpy(ext, DELEXT, strlen(ext));
if (access(recording->FileName(), F_OK) == 0) {
- recording->fileSizeMB = DirSizeMB(recording->FileName());
recording->deleted = time(NULL);
DeletedRecordings.Add(recording);
recording = NULL; // to prevent it from being deleted below
@@ -1241,12 +1250,33 @@ int cRecordings::TotalFileSizeMB(void)
int size = 0;
LOCK_THREAD;
for (cRecording *recording = First(); recording; recording = Next(recording)) {
- if (recording->fileSizeMB > 0 && IsOnVideoDirectoryFileSystem(recording->FileName()))
- size += recording->fileSizeMB;
+ int FileSizeMB = recording->FileSizeMB();
+ if (FileSizeMB > 0 && IsOnVideoDirectoryFileSystem(recording->FileName()))
+ size += FileSizeMB;
}
return size;
}
+double cRecordings::MBperMinute(void)
+{
+ int size = 0;
+ int length = 0;
+ LOCK_THREAD;
+ for (cRecording *recording = First(); recording; recording = Next(recording)) {
+ if (IsOnVideoDirectoryFileSystem(recording->FileName())) {
+ int FileSizeMB = recording->FileSizeMB();
+ if (FileSizeMB > 0) {
+ int LengthInSeconds = recording->LengthInSeconds();
+ if (LengthInSeconds > 0) {
+ size += FileSizeMB;
+ length += LengthInSeconds;
+ }
+ }
+ }
+ }
+ return (size && length) ? double(size) * 60 / length : -1;
+}
+
void cRecordings::ResetResume(const char *ResumeFileName)
{
LOCK_THREAD;