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

Improved error handling in the editing process; message prompt at the end of editing process

This commit is contained in:
Klaus Schmidinger 2002-01-26 13:42:15 +01:00
parent 503c803b8d
commit 4bba577a8b
5 changed files with 92 additions and 16 deletions

View File

@ -907,3 +907,7 @@ Video Disk Recorder Revision History
- Fixed handling file names that contain single quotes (') or dollar signs ($) - Fixed handling file names that contain single quotes (') or dollar signs ($)
in the call to the shutdown command (option '-s') and the recording command in the call to the shutdown command (option '-s') and the recording command
(option '-r'). (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.

View File

@ -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.143 2002/01/13 16:21:48 kls Exp $ * $Id: dvbapi.c 1.144 2002/01/26 13:42:15 kls Exp $
*/ */
//#define DVDDEBUG 1 //#define DVDDEBUG 1
@ -116,7 +116,7 @@ public:
cIndexFile(const char *FileName, bool Record); cIndexFile(const char *FileName, bool Record);
~cIndexFile(); ~cIndexFile();
bool Ok(void) { return index != NULL; } 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); 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 GetNextIFrame(int Index, bool Forward, uchar *FileNumber = NULL, int *FileOffset = NULL, int *Length = NULL, bool StayOffEnd = false);
int Get(uchar FileNumber, int FileOffset); int Get(uchar FileNumber, int FileOffset);
@ -249,7 +249,7 @@ bool cIndexFile::CatchUp(int Index)
return false; return false;
} }
void cIndexFile::Write(uchar PictureType, uchar FileNumber, int FileOffset) bool cIndexFile::Write(uchar PictureType, uchar FileNumber, int FileOffset)
{ {
if (f >= 0) { if (f >= 0) {
tIndex i = { FileOffset, PictureType, FileNumber, 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"); esyslog(LOG_ERR, "ERROR: can't write to index file");
close(f); close(f);
f = -1; f = -1;
return; return false;
} }
last++; last++;
} }
return f >= 0;
} }
bool cIndexFile::Get(int Index, uchar *FileNumber, int *FileOffset, uchar *PictureType, int *Length) bool cIndexFile::Get(int Index, uchar *FileNumber, int *FileOffset, uchar *PictureType, int *Length)
@ -2305,6 +2306,7 @@ void cTransferBuffer::Output(void)
class cCuttingBuffer : public cThread { class cCuttingBuffer : public cThread {
private: private:
const char *error;
bool active; bool active;
int fromFile, toFile; int fromFile, toFile;
cFileName *fromFileName, *toFileName; cFileName *fromFileName, *toFileName;
@ -2315,10 +2317,12 @@ protected:
public: public:
cCuttingBuffer(const char *FromFileName, const char *ToFileName); cCuttingBuffer(const char *FromFileName, const char *ToFileName);
virtual ~cCuttingBuffer(); virtual ~cCuttingBuffer();
const char *Error(void) { return error; }
}; };
cCuttingBuffer::cCuttingBuffer(const char *FromFileName, const char *ToFileName) cCuttingBuffer::cCuttingBuffer(const char *FromFileName, const char *ToFileName)
{ {
error = NULL;
active = false; active = false;
fromFile = toFile = -1; fromFile = toFile = -1;
fromFileName = toFileName = NULL; fromFileName = toFileName = NULL;
@ -2376,11 +2380,15 @@ void cCuttingBuffer::Action(void)
} }
if (fromFile >= 0) { if (fromFile >= 0) {
Length = ReadFrame(fromFile, buffer, Length, sizeof(buffer)); Length = ReadFrame(fromFile, buffer, Length, sizeof(buffer));
if (Length < 0) if (Length < 0) {
error = "ReadFrame";
break; break;
}
} }
else else {
error = "fromFile";
break; break;
}
} }
else else
break; break;
@ -2392,14 +2400,22 @@ void cCuttingBuffer::Action(void)
break; break;
if (FileSize > MEGABYTE(Setup.MaxVideoFileSize)) { if (FileSize > MEGABYTE(Setup.MaxVideoFileSize)) {
toFile = toFileName->NextFile(); toFile = toFileName->NextFile();
if (toFile < 0) if (toFile < 0) {
error = "toFile 1";
break; break;
}
FileSize = 0; FileSize = 0;
} }
LastIFrame = 0; LastIFrame = 0;
} }
safe_write(toFile, buffer, Length); if (safe_write(toFile, buffer, Length) != Length) {
toIndex->Write(PictureType, toFileName->Number(), FileSize); error = "safe_write";
break;
}
if (!toIndex->Write(PictureType, toFileName->Number(), FileSize)) {
error = "toIndex";
break;
}
FileSize += Length; FileSize += Length;
if (!LastIFrame) if (!LastIFrame)
LastIFrame = toIndex->Last(); LastIFrame = toIndex->Last();
@ -2418,8 +2434,10 @@ void cCuttingBuffer::Action(void)
CurrentFileNumber = 0; // triggers SetOffset before reading next frame CurrentFileNumber = 0; // triggers SetOffset before reading next frame
if (Setup.SplitEditedFiles) { if (Setup.SplitEditedFiles) {
toFile = toFileName->NextFile(); toFile = toFileName->NextFile();
if (toFile < 0) if (toFile < 0) {
error = "toFile 2";
break; break;
}
FileSize = 0; FileSize = 0;
} }
} }
@ -2438,10 +2456,14 @@ void cCuttingBuffer::Action(void)
char *cVideoCutter::editedVersionName = NULL; char *cVideoCutter::editedVersionName = NULL;
cCuttingBuffer *cVideoCutter::cuttingBuffer = NULL; cCuttingBuffer *cVideoCutter::cuttingBuffer = NULL;
bool cVideoCutter::error = false;
bool cVideoCutter::ended = false;
bool cVideoCutter::Start(const char *FileName) bool cVideoCutter::Start(const char *FileName)
{ {
if (!cuttingBuffer) { if (!cuttingBuffer) {
error = false;
ended = false;
cRecording Recording(FileName); cRecording Recording(FileName);
const char *evn = Recording.PrefixFileName('%'); const char *evn = Recording.PrefixFileName('%');
if (evn && RemoveVideoFile(evn) && MakeDirs(evn, true)) { if (evn && RemoveVideoFile(evn) && MakeDirs(evn, true)) {
@ -2456,8 +2478,17 @@ bool cVideoCutter::Start(const char *FileName)
void cVideoCutter::Stop(void) void cVideoCutter::Stop(void)
{ {
bool Interrupted = cuttingBuffer && cuttingBuffer->Active();
const char *Error = cuttingBuffer ? cuttingBuffer->Error() : NULL;
delete cuttingBuffer; delete cuttingBuffer;
cuttingBuffer = NULL; 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) bool cVideoCutter::Active(void)
@ -2465,16 +2496,32 @@ bool cVideoCutter::Active(void)
if (cuttingBuffer) { if (cuttingBuffer) {
if (cuttingBuffer->Active()) if (cuttingBuffer->Active())
return true; return true;
error = cuttingBuffer->Error();
Stop(); Stop();
cRecordingUserCommand::InvokeCommand(RUC_EDITEDRECORDING, editedVersionName); if (!error)
cRecordingUserCommand::InvokeCommand(RUC_EDITEDRECORDING, editedVersionName);
delete editedVersionName; delete editedVersionName;
editedVersionName = NULL; editedVersionName = NULL;
ended = true;
} }
return false; 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) static const char *OstName(const char *Name, int n)
{ {

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: dvbapi.h 1.59 2001/11/24 11:03:16 kls Exp $ * $Id: dvbapi.h 1.60 2002/01/26 13:01:16 kls Exp $
*/ */
#ifndef __DVBAPI_H #ifndef __DVBAPI_H
@ -69,10 +69,14 @@ class cVideoCutter {
private: private:
static char *editedVersionName; static char *editedVersionName;
static cCuttingBuffer *cuttingBuffer; static cCuttingBuffer *cuttingBuffer;
static bool error;
static bool ended;
public: public:
static bool Start(const char *FileName); static bool Start(const char *FileName);
static void Stop(void); static void Stop(void);
static bool Active(void); static bool Active(void);
static bool Error(void);
static bool Ended(void);
}; };
class cDvbApi { class cDvbApi {

18
i18n.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: i18n.c 1.46 2002/01/19 16:25:33 kls Exp $ * $Id: i18n.c 1.47 2002/01/26 13:05:54 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>
@ -1382,6 +1382,22 @@ const tPhrase Phrases[] = {
"Opération de montage lancée", "Opération de montage lancée",
"Redigeringsprosess startet", "Redigeringsprosess startet",
}, },
{ "Editing process finished",
"Schnitt beendet",
"", // TODO
"", // TODO
"", // TODO
"", // TODO
"", // TODO
},
{ "Editing process failed!",
"Schnitt gescheitert!",
"", // TODO
"", // TODO
"", // TODO
"", // TODO
"", // TODO
},
{ NULL } { NULL }
}; };

9
vdr.c
View File

@ -22,7 +22,7 @@
* *
* The project's page is at http://www.cadsoft.de/people/kls/vdr * The project's page is at http://www.cadsoft.de/people/kls/vdr
* *
* $Id: vdr.c 1.91 2002/01/26 11:53:11 kls Exp $ * $Id: vdr.c 1.92 2002/01/26 13:35:05 kls Exp $
*/ */
#include <getopt.h> #include <getopt.h>
@ -468,7 +468,12 @@ int main(int argc, char *argv[])
} }
if (!Menu) { if (!Menu) {
EITScanner.Process(); EITScanner.Process();
cVideoCutter::Active(); if (!cVideoCutter::Active() && cVideoCutter::Ended()) {
if (cVideoCutter::Error())
Interface->Error(tr("Editing process failed!"));
else
Interface->Info(tr("Editing process finished"));
}
} }
if (!*Interact && (!cRecordControls::Active() || ForceShutdown)) { if (!*Interact && (!cRecordControls::Active() || ForceShutdown)) {
time_t Now = time(NULL); time_t Now = time(NULL);