1
0
mirror of https://github.com/VDR4Arch/vdr.git synced 2023-10-10 13:36:52 +02:00

When estimating the remaining disk space (in hours), the average data rate of all existing recordings is now taken into account

This commit is contained in:
Klaus Schmidinger 2012-03-13 13:22:06 +01:00
parent 845d6f36c1
commit 71f02e4f80
4 changed files with 54 additions and 12 deletions

View File

@ -7037,3 +7037,6 @@ Video Disk Recorder Revision History
the given device. the given device.
- When toggling a timer between "Single" and "Repeating", the previous setting is now - When toggling a timer between "Single" and "Repeating", the previous setting is now
retained in case the user toggles back to the original value. retained in case the user toggles back to the original value.
- When estimating the remaining disk space (in hours), the average data rate of all
existing recordings is now taken into account. If this value can't be determined,
the previous value of 25.75 MB/min is taken.

7
menu.c
View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: menu.c 2.44 2012/03/11 13:20:45 kls Exp $ * $Id: menu.c 2.45 2012/03/13 13:14:38 kls Exp $
*/ */
#include "menu.h" #include "menu.h"
@ -78,7 +78,10 @@ bool cFreeDiskSpace::HasChanged(bool ForceCheck)
int Percent = VideoDiskSpace(&FreeMB); int Percent = VideoDiskSpace(&FreeMB);
lastDiskSpaceCheck = time(NULL); lastDiskSpaceCheck = time(NULL);
if (ForceCheck || FreeMB != lastFreeMB) { if (ForceCheck || FreeMB != lastFreeMB) {
int Minutes = int(double(FreeMB) / MB_PER_MINUTE); int MBperMinute = Recordings.MBperMinute();
if (MBperMinute <= 0)
MBperMinute = MB_PER_MINUTE;
int Minutes = int(double(FreeMB) / MBperMinute);
int Hours = Minutes / 60; int Hours = Minutes / 60;
Minutes %= 60; Minutes %= 60;
freeDiskSpaceString = cString::sprintf("%s %d%% - %2d:%02d %s", tr("Disk"), Percent, Hours, Minutes, tr("free")); freeDiskSpaceString = cString::sprintf("%s %d%% - %2d:%02d %s", tr("Disk"), Percent, Hours, Minutes, tr("free"));

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * 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" #include "recording.h"
@ -1063,6 +1063,17 @@ int cRecording::LengthInSeconds(void) const
return -1; 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 -----------------------------------------------------------
cRecordings Recordings; cRecordings Recordings;
@ -1127,14 +1138,13 @@ void cRecordings::ScanVideoDir(const char *DirName, bool Foreground, int LinkLev
cRecording *r = new cRecording(buffer); cRecording *r = new cRecording(buffer);
if (r->Name()) { if (r->Name()) {
r->NumFrames(); // initializes the numFrames member r->NumFrames(); // initializes the numFrames member
r->FileSizeMB(); // initializes the fileSizeMB member
if (deleted)
r->deleted = time(NULL);
Lock(); Lock();
Add(r); Add(r);
ChangeState(); ChangeState();
Unlock(); Unlock();
if (deleted) {
r->fileSizeMB = DirSizeMB(buffer);
r->deleted = time(NULL);
}
} }
else else
delete r; delete r;
@ -1216,7 +1226,6 @@ void cRecordings::DelByName(const char *FileName)
if (ext) { if (ext) {
strncpy(ext, DELEXT, strlen(ext)); strncpy(ext, DELEXT, strlen(ext));
if (access(recording->FileName(), F_OK) == 0) { if (access(recording->FileName(), F_OK) == 0) {
recording->fileSizeMB = DirSizeMB(recording->FileName());
recording->deleted = time(NULL); recording->deleted = time(NULL);
DeletedRecordings.Add(recording); DeletedRecordings.Add(recording);
recording = NULL; // to prevent it from being deleted below recording = NULL; // to prevent it from being deleted below
@ -1241,12 +1250,33 @@ int cRecordings::TotalFileSizeMB(void)
int size = 0; int size = 0;
LOCK_THREAD; LOCK_THREAD;
for (cRecording *recording = First(); recording; recording = Next(recording)) { for (cRecording *recording = First(); recording; recording = Next(recording)) {
if (recording->fileSizeMB > 0 && IsOnVideoDirectoryFileSystem(recording->FileName())) int FileSizeMB = recording->FileSizeMB();
size += recording->fileSizeMB; if (FileSizeMB > 0 && IsOnVideoDirectoryFileSystem(recording->FileName()))
size += FileSizeMB;
} }
return size; 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) void cRecordings::ResetResume(const char *ResumeFileName)
{ {
LOCK_THREAD; LOCK_THREAD;

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: recording.h 2.29 2012/03/12 11:44:06 kls Exp $ * $Id: recording.h 2.30 2012/03/13 12:41:05 kls Exp $
*/ */
#ifndef __RECORDING_H #ifndef __RECORDING_H
@ -129,6 +129,9 @@ public:
///< If the number of frames is unknown, -1 will be returned. ///< If the number of frames is unknown, -1 will be returned.
int LengthInSeconds(void) const; int LengthInSeconds(void) const;
///< Returns the length (in seconds) of this recording, or -1 in case of error. ///< Returns the length (in seconds) of this recording, or -1 in case of error.
int FileSizeMB(void) const;
///< Returns the total file size of this recording (in MB), or -1 if the file
///< size is unknown.
bool IsNew(void) const { return GetResume() <= 0; } bool IsNew(void) const { return GetResume() <= 0; }
bool IsEdited(void) const; bool IsEdited(void) const;
bool IsPesRecording(void) const { return isPesRecording; } bool IsPesRecording(void) const { return isPesRecording; }
@ -190,7 +193,10 @@ public:
void AddByName(const char *FileName, bool TriggerUpdate = true); void AddByName(const char *FileName, bool TriggerUpdate = true);
void DelByName(const char *FileName); void DelByName(const char *FileName);
void UpdateByName(const char *FileName); void UpdateByName(const char *FileName);
int TotalFileSizeMB(void); ///< Only for deleted recordings! int TotalFileSizeMB(void);
double MBperMinute(void);
///< Returns the average data rate (in MB/min) of all recordings, or -1 if
///< this value is unknown.
}; };
extern cRecordings Recordings; extern cRecordings Recordings;