From 7df66b05874339d23c1ce35387a8d55579891a22 Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Tue, 16 Aug 2011 18:57:00 +0200 Subject: Version 1.7.20 Original announce message: VDR developer version 1.7.20 is now available at MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ftp://ftp.tvdr.de/vdr/Developer/vdr-1.7.20.tar.bz2 A 'diff' against the previous version is available at ftp://ftp.tvdr.de/vdr/Developer/vdr-1.7.19-1.7.20.diff MD5 checksums: eda2911fff1715ba5b1482b20ad18188 vdr-1.7.20.tar.bz2 a8f5bcaf3294cc9fce87283a618d5ce1 vdr-1.7.19-1.7.20.diff WARNING: ======== This is a developer version. Even though I use it in my productive environment. I strongly recommend that you only use it under controlled conditions and for testing and debugging. This version contains functions to determine the "signal strength" and "signal quality" through cDevice. If you are using a DVB card that contains an stb0899 frontend chip (like the TT-budget S2-3200) you may want to apply the patches from ftp://ftp.tvdr.de/vdr/Developer/Driver-Patches to the LinuxDVB driver source in order to receive useful results from that frontend. From the HISTORY file: - Added some missing 'const' to tChannelID (reported by Sundararaj Reel). - The isnumber() function now checks the given pointer for NULL (thanks to Holger Dengler). - Now checking Setup.InitialChannel for NULL before using it (reported by Christoph Haubrich). - cSkins::Message() now blocks calls from background threads (thanks to Michael Eiler for reporting a crash in such a scenario). - Fixed the return value of the svdrpsend.pl script in case of an error (thanks to Jonas Diemer). - Increased MAXCAIDS to 12 (thanks to Jerome Lacarriere). - Fixed handling DiSEqC codes (thanks to Mark Hawes for reporting the bug, and Udo Richter for suggesting the fix). - Added a mechanism to defer timer handling in case of problems (reported by Frank Niederwipper). - Fixed distortions that happened when splitting recording into several files (was a side effect of "Fixed detecting frames in case the Picture Start Code or Access Unit Delimiter extends over TS packet boundaries" in version 1.7.19). cRecorder::Action() now buffers TS packets in case the frame type is not yet known when a new payload starts. This adds no overhead for channels that broadcast the frame type within the first TS packet of a payload; it only kicks in if that information is not in the first TS packet. - Fixed handling the channelID in cMenuEditChanItem (thanks to Udo Richter). - cStringList::Sort() can now be called with a boolean parameter that controls case insensitive sorting (suggested by Sundararaj Reel). - Now scanning new transponders before old ones, to make sure transponder changes are recognized (thanks to Reinhard Nissl). - Implemented static cIndexFile::IndexFileName(). - The length (as number of frames) of a recording's index file can now be determined by a call to cIndexFile::GetLength() (suggested by Christoph Haubrich). - Fixed some crashes in subtitle display (thanks to Rolf Ahrenberg). - Made DELETENULL() thread safe (reported by Rolf Ahrenberg). - The pic2mpg script of the 'pictures' plugin now generates HD images (thanks to Andre Weidemann for his support in using convert/ffmpeg). The old SD version is still available as pic2mpg-sd. - Added a mutex to protect cOsd::Osds from simultaneous access from different threads (reported by Rolf Ahrenberg). - The cutter now sets the 'broken link' flag for MPEG2 TS recordings (thanks to Oliver Endriss). - Fixed language code entry for Portuguese. - The new command line options --filesize (suggested by Marco Göbenich) and --split can be used together with --edit to set the maximum video file size and turn on splitting edited files at the editing marks. These options must be given before --edit to have an effect. - cTimeMs is no longer initialized to the current time if the value given to the constructor is negative (avoids the "cTimeMs: using monotonic clock..." log message before VDR's starting log message). --- recording.c | 142 +++++++++++++++++++++++++++++++----------------------------- 1 file changed, 73 insertions(+), 69 deletions(-) (limited to 'recording.c') diff --git a/recording.c b/recording.c index a8b40f2..4456bdd 100644 --- a/recording.c +++ b/recording.c @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: recording.c 2.31 2011/06/12 13:04:28 kls Exp $ + * $Id: recording.c 2.33 2011/08/13 12:37:25 kls Exp $ */ #include "recording.h" @@ -1540,84 +1540,75 @@ cIndexFile::cIndexFile(const char *FileName, bool Record, bool IsPesRecording) :resumeFile(FileName, IsPesRecording) { f = -1; - fileName = NULL; size = 0; last = -1; index = NULL; isPesRecording = IsPesRecording; indexFileGenerator = NULL; if (FileName) { - const char *Suffix = isPesRecording ? INDEXFILESUFFIX ".vdr" : INDEXFILESUFFIX; - fileName = MALLOC(char, strlen(FileName) + strlen(Suffix) + 1); - if (fileName) { - strcpy(fileName, FileName); - char *pFileExt = fileName + strlen(fileName); - strcpy(pFileExt, Suffix); - int delta = 0; - if (!Record && access(fileName, R_OK) != 0) { - // Index file doesn't exist, so try to regenerate it: - if (!isPesRecording) { // sorry, can only do this for TS recordings - resumeFile.Delete(); // just in case - indexFileGenerator = new cIndexFileGenerator(FileName); - // Wait until the index file exists: - time_t tmax = time(NULL) + MAXWAITFORINDEXFILE; - do { - cCondWait::SleepMs(INDEXFILECHECKINTERVAL); // start with a sleep, to give it a head start - } while (access(fileName, R_OK) != 0 && time(NULL) < tmax); - } + fileName = IndexFileName(FileName, isPesRecording); + int delta = 0; + if (!Record && access(fileName, R_OK) != 0) { + // Index file doesn't exist, so try to regenerate it: + if (!isPesRecording) { // sorry, can only do this for TS recordings + resumeFile.Delete(); // just in case + indexFileGenerator = new cIndexFileGenerator(FileName); + // Wait until the index file exists: + time_t tmax = time(NULL) + MAXWAITFORINDEXFILE; + do { + cCondWait::SleepMs(INDEXFILECHECKINTERVAL); // start with a sleep, to give it a head start + } while (access(fileName, R_OK) != 0 && time(NULL) < tmax); } - if (access(fileName, R_OK) == 0) { - struct stat buf; - if (stat(fileName, &buf) == 0) { - delta = int(buf.st_size % sizeof(tIndexTs)); - if (delta) { - delta = sizeof(tIndexTs) - delta; - esyslog("ERROR: invalid file size (%"PRId64") in '%s'", buf.st_size, fileName); - } - last = int((buf.st_size + delta) / sizeof(tIndexTs) - 1); - if (!Record && last >= 0) { - size = last + 1; - index = MALLOC(tIndexTs, size); - if (index) { - f = open(fileName, O_RDONLY); - if (f >= 0) { - if (safe_read(f, index, size_t(buf.st_size)) != buf.st_size) { - esyslog("ERROR: can't read from file '%s'", fileName); - free(index); - index = NULL; - close(f); - f = -1; - } - // we don't close f here, see CatchUp()! - else if (isPesRecording) - ConvertFromPes(index, size); + } + if (access(fileName, R_OK) == 0) { + struct stat buf; + if (stat(fileName, &buf) == 0) { + delta = int(buf.st_size % sizeof(tIndexTs)); + if (delta) { + delta = sizeof(tIndexTs) - delta; + esyslog("ERROR: invalid file size (%"PRId64") in '%s'", buf.st_size, *fileName); + } + last = int((buf.st_size + delta) / sizeof(tIndexTs) - 1); + if (!Record && last >= 0) { + size = last + 1; + index = MALLOC(tIndexTs, size); + if (index) { + f = open(fileName, O_RDONLY); + if (f >= 0) { + if (safe_read(f, index, size_t(buf.st_size)) != buf.st_size) { + esyslog("ERROR: can't read from file '%s'", *fileName); + free(index); + index = NULL; + close(f); + f = -1; } - else - LOG_ERROR_STR(fileName); + // we don't close f here, see CatchUp()! + else if (isPesRecording) + ConvertFromPes(index, size); } else - esyslog("ERROR: can't allocate %zd bytes for index '%s'", size * sizeof(tIndexTs), fileName); + LOG_ERROR_STR(*fileName); } + else + esyslog("ERROR: can't allocate %zd bytes for index '%s'", size * sizeof(tIndexTs), *fileName); } - else - LOG_ERROR; } - else if (!Record) - isyslog("missing index file %s", fileName); - if (Record) { - if ((f = open(fileName, O_WRONLY | O_CREAT | O_APPEND, DEFFILEMODE)) >= 0) { - if (delta) { - esyslog("ERROR: padding index file with %d '0' bytes", delta); - while (delta--) - writechar(f, 0); - } + else + LOG_ERROR; + } + else if (!Record) + isyslog("missing index file %s", *fileName); + if (Record) { + if ((f = open(fileName, O_WRONLY | O_CREAT | O_APPEND, DEFFILEMODE)) >= 0) { + if (delta) { + esyslog("ERROR: padding index file with %d '0' bytes", delta); + while (delta--) + writechar(f, 0); } - else - LOG_ERROR_STR(fileName); } + else + LOG_ERROR_STR(*fileName); } - else - esyslog("ERROR: can't copy file name '%s'", FileName); } } @@ -1625,11 +1616,15 @@ cIndexFile::~cIndexFile() { if (f >= 0) close(f); - free(fileName); free(index); delete indexFileGenerator; } +cString cIndexFile::IndexFileName(const char *FileName, bool IsPesRecording) +{ + return cString::sprintf("%s%s", FileName, IsPesRecording ? INDEXFILESUFFIX ".vdr" : INDEXFILESUFFIX); +} + void cIndexFile::ConvertFromPes(tIndexTs *IndexTs, int Count) { tIndexPes IndexPes; @@ -1696,7 +1691,7 @@ bool cIndexFile::CatchUp(int Index) last = newLast; } else - LOG_ERROR_STR(fileName); + LOG_ERROR_STR(*fileName); } else { esyslog("ERROR: can't realloc() index"); @@ -1705,7 +1700,7 @@ bool cIndexFile::CatchUp(int Index) } } else - LOG_ERROR_STR(fileName); + LOG_ERROR_STR(*fileName); if (Index < last - (i ? 2 * INDEXSAFETYLIMIT : 0) || Index > 10 * INDEXSAFETYLIMIT) // keep off the end in case of "Pause live video" break; cCondWait::SleepMs(1000); @@ -1721,7 +1716,7 @@ bool cIndexFile::Write(bool Independent, uint16_t FileNumber, off_t FileOffset) if (isPesRecording) ConvertToPes(&i, 1); if (safe_write(f, &i, sizeof(i)) < 0) { - LOG_ERROR_STR(fileName); + LOG_ERROR_STR(*fileName); close(f); f = -1; return false; @@ -1811,8 +1806,8 @@ bool cIndexFile::IsStillRecording() void cIndexFile::Delete(void) { - if (fileName) { - dsyslog("deleting index file '%s'", fileName); + if (*fileName) { + dsyslog("deleting index file '%s'", *fileName); if (f >= 0) { close(f); f = -1; @@ -1821,6 +1816,15 @@ void cIndexFile::Delete(void) } } +int cIndexFile::GetLength(const char *FileName, bool IsPesRecording) +{ + struct stat buf; + cString s = IndexFileName(FileName, IsPesRecording); + if (*s && stat(s, &buf) == 0) + return buf.st_size / (IsPesRecording ? sizeof(tIndexTs) : sizeof(tIndexPes)); + return -1; +} + bool GenerateIndex(const char *FileName) { if (DirectoryOk(FileName)) { -- cgit v1.2.3