summaryrefslogtreecommitdiff
path: root/dvbapi.c
diff options
context:
space:
mode:
authorKlaus Schmidinger <kls (at) cadsoft (dot) de>2002-01-27 18:00:00 +0100
committerKlaus Schmidinger <kls (at) cadsoft (dot) de>2002-01-27 18:00:00 +0100
commit27919ee969866b68fc95b327a047a9989e4b4153 (patch)
tree1857862abf169ff6e9287152cd6fec6a1d9dbc41 /dvbapi.c
parentb420457467ad0c8ae71f8b985914e85b7a0ff5aa (diff)
downloadvdr-patch-lnbsharing-27919ee969866b68fc95b327a047a9989e4b4153.tar.gz
vdr-patch-lnbsharing-27919ee969866b68fc95b327a047a9989e4b4153.tar.bz2
Version 0.99pre2vdr-0.99pre2
- Fixed setting the OSD size in the 'Confirm' interface call (thanks to Deti Fliegl). - Removed the 'read incomplete section...' error message in the EIT processor. - Fixed channel data for "DW TV" (thanks to Axel Gruber). - Added DPID to "PREMIERE MOVIE 1" in channels.conf.cable (thanks to Stephan Schreiber). - Prepared the OSD functions for multiple overlapping windows. - Removed the check to see whether the system time is running linearly. - Improved performance of SVDRP command entry. - Removed EPGBugfixLevel '3' - after more than a year Pro-7 finally managed to broadcast the correct timestamps for EPG events between 0:00 and 6:00! - Fixed failing watchdog timer if program hangs in OSD activities (thanks to Carsten Koch). - No longer requiring 'libncurses' if compiling without DEBUG_OSD=1 and REMOTE=KBD (thanks to Lauri Pesonen). - The "Recordings" menu now displays a hierarchical structure if there are subdirectories for the recordings. This can be controlled through the "RecordingDirs" parameter in the "Setup" menu. See "MANUAL/Replaying a Recording" for details. - Improved speed of setting the Help button texts. - Fixed handling file names that contain single quotes (') or dollar signs ($) in the call to the shutdown command (option '-s') and the recording command (option '-r'). - Improved error handling in the editing process; the resulting file will be deleted if an error occured. - A message is now prompted at the end of the editing process, indicating whether the process succeeded or failed. - Fixed setting the LastActivity timestamp after a shutdown prompt (thanks to Sergei Haller). - A message is now prompted if free disk space becomes low during recording. - The editing process now calls AssertFreeDiskSpace() to remove deleted 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. - Activating the "Recordings" menu now displays "scanning recordings..." to give the user some feedback in case this takes longer. - Status messages are now displayed centered. - Removed the 'Tools' subdirectory from the VDR archive. All contributed tools can now be found at ftp://ftp.cadsoft.de/pub/people/kls/vdr/Tools.
Diffstat (limited to 'dvbapi.c')
-rw-r--r--dvbapi.c87
1 files changed, 71 insertions, 16 deletions
diff --git a/dvbapi.c b/dvbapi.c
index 707db0d..048639c 100644
--- a/dvbapi.c
+++ b/dvbapi.c
@@ -7,7 +7,7 @@
* DVD support initially written by Andreas Schultz <aschultz@warp10.net>
* based on dvdplayer-0.5 by Matjaz Thaler <matjaz.thaler@guest.arnes.si>
*
- * $Id: dvbapi.c 1.141 2001/11/25 16:38:09 kls Exp $
+ * $Id: dvbapi.c 1.146 2002/01/26 15:39:48 kls Exp $
*/
//#define DVDDEBUG 1
@@ -116,7 +116,7 @@ public:
cIndexFile(const char *FileName, bool Record);
~cIndexFile();
bool Ok(void) { return index != NULL; }
- void Write(uchar PictureType, uchar FileNumber, int FileOffset);
+ bool Write(uchar PictureType, uchar FileNumber, int FileOffset);
bool Get(int Index, uchar *FileNumber, int *FileOffset, uchar *PictureType = NULL, int *Length = NULL);
int GetNextIFrame(int Index, bool Forward, uchar *FileNumber = NULL, int *FileOffset = NULL, int *Length = NULL, bool StayOffEnd = false);
int Get(uchar FileNumber, int FileOffset);
@@ -146,7 +146,7 @@ cIndexFile::cIndexFile(const char *FileName, bool Record)
delta = buf.st_size % sizeof(tIndex);
if (delta) {
delta = sizeof(tIndex) - delta;
- esyslog(LOG_ERR, "ERROR: invalid file size (%d) in '%s'", buf.st_size, fileName);
+ esyslog(LOG_ERR, "ERROR: invalid file size (%ld) in '%s'", buf.st_size, fileName);
}
last = (buf.st_size + delta) / sizeof(tIndex) - 1;
if (!Record && last >= 0) {
@@ -249,7 +249,7 @@ bool cIndexFile::CatchUp(int Index)
return false;
}
-void cIndexFile::Write(uchar PictureType, uchar FileNumber, int FileOffset)
+bool cIndexFile::Write(uchar PictureType, uchar FileNumber, int FileOffset)
{
if (f >= 0) {
tIndex i = { FileOffset, PictureType, FileNumber, 0 };
@@ -257,10 +257,11 @@ void cIndexFile::Write(uchar PictureType, uchar FileNumber, int FileOffset)
esyslog(LOG_ERR, "ERROR: can't write to index file");
close(f);
f = -1;
- return;
+ return false;
}
last++;
}
+ return f >= 0;
}
bool cIndexFile::Get(int Index, uchar *FileNumber, int *FileOffset, uchar *PictureType, int *Length)
@@ -506,7 +507,7 @@ cRecordBuffer::~cRecordBuffer()
bool cRecordBuffer::RunningLowOnDiskSpace(void)
{
if (time(NULL) > lastDiskSpaceCheck + DISKCHECKINTERVAL) {
- uint Free = FreeDiskSpaceMB(fileName.Name());
+ int Free = FreeDiskSpaceMB(fileName.Name());
lastDiskSpaceCheck = time(NULL);
if (Free < MINFREEDISKSPACE) {
dsyslog(LOG_INFO, "low disk space (%d MB, limit is %d MB)", Free, MINFREEDISKSPACE);
@@ -2305,6 +2306,7 @@ void cTransferBuffer::Output(void)
class cCuttingBuffer : public cThread {
private:
+ const char *error;
bool active;
int fromFile, toFile;
cFileName *fromFileName, *toFileName;
@@ -2315,10 +2317,12 @@ protected:
public:
cCuttingBuffer(const char *FromFileName, const char *ToFileName);
virtual ~cCuttingBuffer();
+ const char *Error(void) { return error; }
};
cCuttingBuffer::cCuttingBuffer(const char *FromFileName, const char *ToFileName)
{
+ error = NULL;
active = false;
fromFile = toFile = -1;
fromFileName = toFileName = NULL;
@@ -2367,6 +2371,10 @@ void cCuttingBuffer::Action(void)
int FileOffset, Length;
uchar PictureType;
+ // Make sure there is enough disk space:
+
+ AssertFreeDiskSpace();
+
// Read one frame:
if (fromIndex->Get(Index++, &FileNumber, &FileOffset, &PictureType, &Length)) {
@@ -2376,11 +2384,15 @@ void cCuttingBuffer::Action(void)
}
if (fromFile >= 0) {
Length = ReadFrame(fromFile, buffer, Length, sizeof(buffer));
- if (Length < 0)
+ if (Length < 0) {
+ error = "ReadFrame";
break;
+ }
}
- else
+ else {
+ error = "fromFile";
break;
+ }
}
else
break;
@@ -2392,14 +2404,22 @@ void cCuttingBuffer::Action(void)
break;
if (FileSize > MEGABYTE(Setup.MaxVideoFileSize)) {
toFile = toFileName->NextFile();
- if (toFile < 0)
+ if (toFile < 0) {
+ error = "toFile 1";
break;
+ }
FileSize = 0;
}
LastIFrame = 0;
}
- safe_write(toFile, buffer, Length);
- toIndex->Write(PictureType, toFileName->Number(), FileSize);
+ if (safe_write(toFile, buffer, Length) != Length) {
+ error = "safe_write";
+ break;
+ }
+ if (!toIndex->Write(PictureType, toFileName->Number(), FileSize)) {
+ error = "toIndex";
+ break;
+ }
FileSize += Length;
if (!LastIFrame)
LastIFrame = toIndex->Last();
@@ -2418,8 +2438,10 @@ void cCuttingBuffer::Action(void)
CurrentFileNumber = 0; // triggers SetOffset before reading next frame
if (Setup.SplitEditedFiles) {
toFile = toFileName->NextFile();
- if (toFile < 0)
+ if (toFile < 0) {
+ error = "toFile 2";
break;
+ }
FileSize = 0;
}
}
@@ -2438,10 +2460,14 @@ void cCuttingBuffer::Action(void)
char *cVideoCutter::editedVersionName = NULL;
cCuttingBuffer *cVideoCutter::cuttingBuffer = NULL;
+bool cVideoCutter::error = false;
+bool cVideoCutter::ended = false;
bool cVideoCutter::Start(const char *FileName)
{
if (!cuttingBuffer) {
+ error = false;
+ ended = false;
cRecording Recording(FileName);
const char *evn = Recording.PrefixFileName('%');
if (evn && RemoveVideoFile(evn) && MakeDirs(evn, true)) {
@@ -2456,8 +2482,17 @@ bool cVideoCutter::Start(const char *FileName)
void cVideoCutter::Stop(void)
{
+ bool Interrupted = cuttingBuffer && cuttingBuffer->Active();
+ const char *Error = cuttingBuffer ? cuttingBuffer->Error() : NULL;
delete cuttingBuffer;
cuttingBuffer = NULL;
+ if ((Interrupted || Error) && editedVersionName) {
+ if (Interrupted)
+ isyslog(LOG_INFO, "editing process has been interrupted");
+ if (Error)
+ esyslog(LOG_ERR, "ERROR: '%s' during editing process", Error);
+ RemoveVideoFile(editedVersionName); //XXX what if this file is currently being replayed?
+ }
}
bool cVideoCutter::Active(void)
@@ -2465,16 +2500,32 @@ bool cVideoCutter::Active(void)
if (cuttingBuffer) {
if (cuttingBuffer->Active())
return true;
+ error = cuttingBuffer->Error();
Stop();
- cRecordingUserCommand::InvokeCommand(RUC_EDITEDRECORDING, editedVersionName);
+ if (!error)
+ cRecordingUserCommand::InvokeCommand(RUC_EDITEDRECORDING, editedVersionName);
delete editedVersionName;
editedVersionName = NULL;
+ ended = true;
}
return false;
}
-// --- cDvbApi ---------------------------------------------------------------
+bool cVideoCutter::Error(void)
+{
+ bool result = error;
+ error = false;
+ return result;
+}
+bool cVideoCutter::Ended(void)
+{
+ bool result = ended;
+ ended = false;
+ return result;
+}
+
+// --- cDvbApi ---------------------------------------------------------------
static const char *OstName(const char *Name, int n)
{
@@ -2842,7 +2893,11 @@ void cDvbApi::Open(int w, int h)
}
else if (d == 0) { //XXX full menu
osd->Create(0, 0, w, lineHeight, 2);
- osd->Create(0, lineHeight, w, (Setup.OSDheight - 3) * lineHeight, 2, true, clrBackground, clrCyan, clrWhite, clrBlack);
+ osd->Create(0, lineHeight, w, (Setup.OSDheight - 3) * lineHeight, 2);
+ osd->AddColor(clrBackground);
+ osd->AddColor(clrCyan);
+ osd->AddColor(clrWhite);
+ osd->AddColor(clrBlack);
osd->Create(0, (Setup.OSDheight - 2) * lineHeight, w, 2 * lineHeight, 4);
}
else { //XXX progress display
@@ -3197,7 +3252,7 @@ eSetChannelResult cDvbApi::SetChannel(int ChannelNumber, int Frequency, char Pol
}
}
else
- esyslog(LOG_ERR, "ERROR %d in frontend get event", res);
+ esyslog(LOG_ERR, "ERROR %d in frontend get event (channel %d, card %d)", res, ChannelNumber, CardIndex() + 1);
}
else
esyslog(LOG_ERR, "ERROR: timeout while tuning");