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

Added checks for debug file i/o

This commit is contained in:
Klaus Schmidinger 2013-09-07 10:39:46 +02:00
parent 699454ad7f
commit 3c72be23f0

View File

@ -7,7 +7,7 @@
* Original author: Marco Schluessler <marco@lordzodiac.de> * Original author: Marco Schluessler <marco@lordzodiac.de>
* With some input from the "subtitles plugin" by Pekka Virtanen <pekka.virtanen@sci.fi> * With some input from the "subtitles plugin" by Pekka Virtanen <pekka.virtanen@sci.fi>
* *
* $Id: dvbsubtitle.c 3.3 2013/09/06 12:16:16 kls Exp $ * $Id: dvbsubtitle.c 3.4 2013/09/07 10:39:46 kls Exp $
*/ */
#include "dvbsubtitle.h" #include "dvbsubtitle.h"
@ -106,9 +106,11 @@ cString cSubtitleDebug::WriteJpeg(const cBitmap *Bitmap, int MaxX, int MaxY)
uchar *Jpeg = RgbToJpeg(mem, w, h, Size); uchar *Jpeg = RgbToJpeg(mem, w, h, Size);
cString ImgName = cString::sprintf("dbg-%03d.jpg", imgCnt++); cString ImgName = cString::sprintf("dbg-%03d.jpg", imgCnt++);
int f = open(ImgName, O_WRONLY | O_CREAT, DEFFILEMODE); int f = open(ImgName, O_WRONLY | O_CREAT, DEFFILEMODE);
if (write(f, Jpeg, Size) < 0) if (f >= 0) {
LOG_ERROR_STR(*ImgName); if (write(f, Jpeg, Size) < 0)
close(f); LOG_ERROR_STR(*ImgName);
close(f);
}
free(Jpeg); free(Jpeg);
return ImgName; return ImgName;
} }
@ -118,13 +120,14 @@ void cSubtitleDebug::WriteHtml(const char *Format, ...)
if (!Active()) if (!Active())
return; return;
cMutexLock MutexLock(&mutex); cMutexLock MutexLock(&mutex);
FILE *f = fopen("dbg-log.htm", newFile ? "w" : "a"); if (FILE *f = fopen("dbg-log.htm", newFile ? "w" : "a")) {
va_list ap; va_list ap;
va_start(ap, Format); va_start(ap, Format);
vfprintf(f, Format, ap); vfprintf(f, Format, ap);
va_end(ap); va_end(ap);
fclose(f); fclose(f);
newFile = false; newFile = false;
}
} }
static cSubtitleDebug SD; static cSubtitleDebug SD;