mirror of
https://github.com/VDR4Arch/vdr.git
synced 2023-10-10 13:36:52 +02:00
The 'Main' menu now displays the used disk space in the title
This commit is contained in:
parent
53c5499a0b
commit
28e54bc648
5
HISTORY
5
HISTORY
@ -879,7 +879,7 @@ Video Disk Recorder Revision History
|
|||||||
- Fixed DVD audio sync problems (thanks to Andreas Schultz).
|
- Fixed DVD audio sync problems (thanks to Andreas Schultz).
|
||||||
- Fixed external AC3 replay for DVDs (thanks to Andreas Schultz).
|
- Fixed external AC3 replay for DVDs (thanks to Andreas Schultz).
|
||||||
|
|
||||||
2002-01-26: Version 0.99pre2
|
2002-01-27: Version 0.99pre2
|
||||||
|
|
||||||
- Fixed setting the OSD size in the 'Confirm' interface call (thanks to
|
- Fixed setting the OSD size in the 'Confirm' interface call (thanks to
|
||||||
Deti Fliegl).
|
Deti Fliegl).
|
||||||
@ -916,3 +916,6 @@ Video Disk Recorder Revision History
|
|||||||
- A message is now prompted if free disk space becomes low during recording.
|
- A message is now prompted if free disk space becomes low during recording.
|
||||||
- The editing process now calls AssertFreeDiskSpace() to remove deleted
|
- The editing process now calls AssertFreeDiskSpace() to remove deleted
|
||||||
recordings if the disk becomes full.
|
recordings if the disk becomes full.
|
||||||
|
- The "Main" menu now displays in its title the used disk space (in percent)
|
||||||
|
and the estimated free disk space (in hh:mm), assuming a data rate of 30 MB
|
||||||
|
per minute.
|
||||||
|
4
dvbapi.c
4
dvbapi.c
@ -7,7 +7,7 @@
|
|||||||
* DVD support initially written by Andreas Schultz <aschultz@warp10.net>
|
* DVD support initially written by Andreas Schultz <aschultz@warp10.net>
|
||||||
* based on dvdplayer-0.5 by Matjaz Thaler <matjaz.thaler@guest.arnes.si>
|
* based on dvdplayer-0.5 by Matjaz Thaler <matjaz.thaler@guest.arnes.si>
|
||||||
*
|
*
|
||||||
* $Id: dvbapi.c 1.145 2002/01/26 15:28:41 kls Exp $
|
* $Id: dvbapi.c 1.146 2002/01/26 15:39:48 kls Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//#define DVDDEBUG 1
|
//#define DVDDEBUG 1
|
||||||
@ -507,7 +507,7 @@ cRecordBuffer::~cRecordBuffer()
|
|||||||
bool cRecordBuffer::RunningLowOnDiskSpace(void)
|
bool cRecordBuffer::RunningLowOnDiskSpace(void)
|
||||||
{
|
{
|
||||||
if (time(NULL) > lastDiskSpaceCheck + DISKCHECKINTERVAL) {
|
if (time(NULL) > lastDiskSpaceCheck + DISKCHECKINTERVAL) {
|
||||||
uint Free = FreeDiskSpaceMB(fileName.Name());
|
int Free = FreeDiskSpaceMB(fileName.Name());
|
||||||
lastDiskSpaceCheck = time(NULL);
|
lastDiskSpaceCheck = time(NULL);
|
||||||
if (Free < MINFREEDISKSPACE) {
|
if (Free < MINFREEDISKSPACE) {
|
||||||
dsyslog(LOG_INFO, "low disk space (%d MB, limit is %d MB)", Free, MINFREEDISKSPACE);
|
dsyslog(LOG_INFO, "low disk space (%d MB, limit is %d MB)", Free, MINFREEDISKSPACE);
|
||||||
|
10
i18n.c
10
i18n.c
@ -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: i18n.c 1.48 2002/01/26 15:21:40 kls Exp $
|
* $Id: i18n.c 1.49 2002/01/27 13:11:23 kls Exp $
|
||||||
*
|
*
|
||||||
* Slovenian translations provided by Miha Setina <mihasetina@softhome.net>
|
* Slovenian translations provided by Miha Setina <mihasetina@softhome.net>
|
||||||
* Italian translations provided by Alberto Carraro <bertocar@tin.it>
|
* Italian translations provided by Alberto Carraro <bertocar@tin.it>
|
||||||
@ -1329,6 +1329,14 @@ const tPhrase Phrases[] = {
|
|||||||
"bas",
|
"bas",
|
||||||
"", // TODO
|
"", // TODO
|
||||||
},
|
},
|
||||||
|
{ "free",
|
||||||
|
"frei",
|
||||||
|
"", // TODO
|
||||||
|
"", // TODO
|
||||||
|
"", // TODO
|
||||||
|
"", // TODO
|
||||||
|
"", // TODO
|
||||||
|
},
|
||||||
{ "Jump: ", // note the trailing blank
|
{ "Jump: ", // note the trailing blank
|
||||||
"Springen: ",
|
"Springen: ",
|
||||||
"", // TODO
|
"", // TODO
|
||||||
|
15
menu.c
15
menu.c
@ -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 1.144 2002/01/26 11:09:25 kls Exp $
|
* $Id: menu.c 1.145 2002/01/27 13:09:49 kls Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "menu.h"
|
#include "menu.h"
|
||||||
@ -15,6 +15,7 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "eit.h"
|
#include "eit.h"
|
||||||
#include "i18n.h"
|
#include "i18n.h"
|
||||||
|
#include "videodir.h"
|
||||||
|
|
||||||
#define MENUTIMEOUT 120 // seconds
|
#define MENUTIMEOUT 120 // seconds
|
||||||
#define MAXWAIT4EPGINFO 10 // seconds
|
#define MAXWAIT4EPGINFO 10 // seconds
|
||||||
@ -1936,6 +1937,18 @@ cMenuMain::cMenuMain(bool Replaying, eOSState State)
|
|||||||
{
|
{
|
||||||
digit = 0;
|
digit = 0;
|
||||||
|
|
||||||
|
// Title with disk usage:
|
||||||
|
|
||||||
|
#define MB_PER_MINUTE 30 // this is just an estimate!
|
||||||
|
|
||||||
|
char buffer[40];
|
||||||
|
int FreeMB;
|
||||||
|
int Percent = VideoDiskSpace(&FreeMB);
|
||||||
|
int Hours = int(double(FreeMB) / MB_PER_MINUTE / 60);
|
||||||
|
int Minutes = (FreeMB / MB_PER_MINUTE) % 60;
|
||||||
|
snprintf(buffer, sizeof(buffer), "%s - Disk %d%% - %2d:%02d %s", tr("Main"), Percent, Hours, Minutes, tr("free"));
|
||||||
|
SetTitle(buffer);
|
||||||
|
|
||||||
// Basic menu items:
|
// Basic menu items:
|
||||||
|
|
||||||
Add(new cOsdItem(hk(tr("Schedule")), osSchedule));
|
Add(new cOsdItem(hk(tr("Schedule")), osSchedule));
|
||||||
|
14
tools.c
14
tools.c
@ -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: tools.c 1.52 2002/01/26 12:04:32 kls Exp $
|
* $Id: tools.c 1.53 2002/01/27 12:36:23 kls Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "tools.h"
|
#include "tools.h"
|
||||||
@ -223,10 +223,12 @@ const char *AddDirectory(const char *DirName, const char *FileName)
|
|||||||
|
|
||||||
#define DFCMD "df -m -P '%s'"
|
#define DFCMD "df -m -P '%s'"
|
||||||
|
|
||||||
uint FreeDiskSpaceMB(const char *Directory)
|
int FreeDiskSpaceMB(const char *Directory, int *UsedMB)
|
||||||
{
|
{
|
||||||
//TODO Find a simpler way to determine the amount of free disk space!
|
//TODO Find a simpler way to determine the amount of free disk space!
|
||||||
uint Free = 0;
|
if (UsedMB)
|
||||||
|
*UsedMB = 0;
|
||||||
|
int Free = 0;
|
||||||
char *cmd = NULL;
|
char *cmd = NULL;
|
||||||
asprintf(&cmd, DFCMD, Directory);
|
asprintf(&cmd, DFCMD, Directory);
|
||||||
FILE *p = popen(cmd, "r");
|
FILE *p = popen(cmd, "r");
|
||||||
@ -234,8 +236,10 @@ uint FreeDiskSpaceMB(const char *Directory)
|
|||||||
char *s;
|
char *s;
|
||||||
while ((s = readline(p)) != NULL) {
|
while ((s = readline(p)) != NULL) {
|
||||||
if (strchr(s, '/')) {
|
if (strchr(s, '/')) {
|
||||||
uint available;
|
int used, available;
|
||||||
sscanf(s, "%*s %*d %*d %u", &available);
|
sscanf(s, "%*s %*d %d %d", &used, &available);
|
||||||
|
if (UsedMB)
|
||||||
|
*UsedMB = used;
|
||||||
Free = available;
|
Free = available;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
4
tools.h
4
tools.h
@ -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: tools.h 1.38 2002/01/26 11:55:06 kls Exp $
|
* $Id: tools.h 1.39 2002/01/26 15:38:10 kls Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __TOOLS_H
|
#ifndef __TOOLS_H
|
||||||
@ -58,7 +58,7 @@ int time_ms(void);
|
|||||||
void delay_ms(int ms);
|
void delay_ms(int ms);
|
||||||
bool isnumber(const char *s);
|
bool isnumber(const char *s);
|
||||||
const char *AddDirectory(const char *DirName, const char *FileName); // returns a statically allocated string!
|
const char *AddDirectory(const char *DirName, const char *FileName); // returns a statically allocated string!
|
||||||
uint FreeDiskSpaceMB(const char *Directory);
|
int FreeDiskSpaceMB(const char *Directory, int *UsedMB = NULL);
|
||||||
bool DirectoryOk(const char *DirName, bool LogErrors = false);
|
bool DirectoryOk(const char *DirName, bool LogErrors = false);
|
||||||
bool MakeDirs(const char *FileName, bool IsDirectory = false);
|
bool MakeDirs(const char *FileName, bool IsDirectory = false);
|
||||||
bool RemoveFileOrDir(const char *FileName, bool FollowSymlinks = false);
|
bool RemoveFileOrDir(const char *FileName, bool FollowSymlinks = false);
|
||||||
|
30
videodir.c
30
videodir.c
@ -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: videodir.c 1.6 2001/09/02 14:55:15 kls Exp $
|
* $Id: videodir.c 1.7 2002/01/27 12:37:26 kls Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "videodir.h"
|
#include "videodir.h"
|
||||||
@ -27,7 +27,7 @@ private:
|
|||||||
public:
|
public:
|
||||||
cVideoDirectory(void);
|
cVideoDirectory(void);
|
||||||
~cVideoDirectory();
|
~cVideoDirectory();
|
||||||
uint FreeMB(void);
|
int FreeMB(int *UsedMB = NULL);
|
||||||
const char *Name(void) { return name ? name : VideoDirectory; }
|
const char *Name(void) { return name ? name : VideoDirectory; }
|
||||||
const char *Stored(void) { return stored; }
|
const char *Stored(void) { return stored; }
|
||||||
int Length(void) { return length; }
|
int Length(void) { return length; }
|
||||||
@ -53,9 +53,9 @@ cVideoDirectory::~cVideoDirectory()
|
|||||||
delete adjusted;
|
delete adjusted;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint cVideoDirectory::FreeMB(void)
|
int cVideoDirectory::FreeMB(int *UsedMB)
|
||||||
{
|
{
|
||||||
return FreeDiskSpaceMB(name ? name : VideoDirectory);
|
return FreeDiskSpaceMB(name ? name : VideoDirectory, UsedMB);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cVideoDirectory::Next(void)
|
bool cVideoDirectory::Next(void)
|
||||||
@ -117,9 +117,9 @@ int OpenVideoFile(const char *FileName, int Flags)
|
|||||||
cVideoDirectory Dir;
|
cVideoDirectory Dir;
|
||||||
if (Dir.IsDistributed()) {
|
if (Dir.IsDistributed()) {
|
||||||
// Find the directory with the most free space:
|
// Find the directory with the most free space:
|
||||||
uint MaxFree = Dir.FreeMB();
|
int MaxFree = Dir.FreeMB();
|
||||||
while (Dir.Next()) {
|
while (Dir.Next()) {
|
||||||
uint Free = FreeDiskSpaceMB(Dir.Name());
|
int Free = FreeDiskSpaceMB(Dir.Name());
|
||||||
if (Free > MaxFree) {
|
if (Free > MaxFree) {
|
||||||
Dir.Store();
|
Dir.Store();
|
||||||
MaxFree = Free;
|
MaxFree = Free;
|
||||||
@ -166,7 +166,7 @@ bool RemoveVideoFile(const char *FileName)
|
|||||||
return RemoveFileOrDir(FileName, true);
|
return RemoveFileOrDir(FileName, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VideoFileSpaceAvailable(unsigned int SizeMB)
|
bool VideoFileSpaceAvailable(int SizeMB)
|
||||||
{
|
{
|
||||||
cVideoDirectory Dir;
|
cVideoDirectory Dir;
|
||||||
if (Dir.IsDistributed()) {
|
if (Dir.IsDistributed()) {
|
||||||
@ -181,6 +181,22 @@ bool VideoFileSpaceAvailable(unsigned int SizeMB)
|
|||||||
return Dir.FreeMB() >= SizeMB;
|
return Dir.FreeMB() >= SizeMB;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int VideoDiskSpace(int *FreeMB, int *UsedMB)
|
||||||
|
{
|
||||||
|
int free = 0, used = 0;
|
||||||
|
cVideoDirectory Dir;
|
||||||
|
do {
|
||||||
|
int u;
|
||||||
|
free += Dir.FreeMB(&u);
|
||||||
|
used += u;
|
||||||
|
} while (Dir.Next());
|
||||||
|
if (FreeMB)
|
||||||
|
*FreeMB = free;
|
||||||
|
if (UsedMB)
|
||||||
|
*UsedMB = used;
|
||||||
|
return (free + used) ? used * 100 / (free + used) : 0;
|
||||||
|
}
|
||||||
|
|
||||||
const char *PrefixVideoFileName(const char *FileName, char Prefix)
|
const char *PrefixVideoFileName(const char *FileName, char Prefix)
|
||||||
{
|
{
|
||||||
static char *PrefixedName = NULL;
|
static char *PrefixedName = NULL;
|
||||||
|
@ -4,19 +4,22 @@
|
|||||||
* 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: videodir.h 1.3 2001/02/11 13:12:50 kls Exp $
|
* $Id: videodir.h 1.4 2002/01/27 12:37:20 kls Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __VIDEODIR_H
|
#ifndef __VIDEODIR_H
|
||||||
#define __VIDEODIR_H
|
#define __VIDEODIR_H
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
extern const char *VideoDirectory;
|
extern const char *VideoDirectory;
|
||||||
|
|
||||||
int OpenVideoFile(const char *FileName, int Flags);
|
int OpenVideoFile(const char *FileName, int Flags);
|
||||||
int CloseVideoFile(int FileHandle);
|
int CloseVideoFile(int FileHandle);
|
||||||
bool RenameVideoFile(const char *OldName, const char *NewName);
|
bool RenameVideoFile(const char *OldName, const char *NewName);
|
||||||
bool RemoveVideoFile(const char *FileName);
|
bool RemoveVideoFile(const char *FileName);
|
||||||
bool VideoFileSpaceAvailable(unsigned int SizeMB);
|
bool VideoFileSpaceAvailable(int SizeMB);
|
||||||
|
int VideoDiskSpace(int *FreeMB = NULL, int *UsedMB = NULL); // returns the used disk space in percent
|
||||||
const char *PrefixVideoFileName(const char *FileName, char Prefix);
|
const char *PrefixVideoFileName(const char *FileName, char Prefix);
|
||||||
void RemoveEmptyVideoDirectories(void);
|
void RemoveEmptyVideoDirectories(void);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user