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

Fixed handling the very last entry in a recording index

This commit is contained in:
Klaus Schmidinger 2012-11-12 14:50:02 +01:00
parent 1a1b7234ea
commit b951ca48a5
2 changed files with 22 additions and 17 deletions

View File

@ -7272,7 +7272,7 @@ Video Disk Recorder Revision History
".keep" to prevent a directory from being deleted when it is empty. Currently the ".keep" to prevent a directory from being deleted when it is empty. Currently the
only file name that is ignored is ".sort". only file name that is ignored is ".sort".
2012-11-06: Version 1.7.32 2012-11-12: Version 1.7.32
- Pressing the Play key during normal live viewing mode now opens the Recordings menu - Pressing the Play key during normal live viewing mode now opens the Recordings menu
if there is no "last viewed" recording (thanks to Alexander Wenzel). if there is no "last viewed" recording (thanks to Alexander Wenzel).
@ -7311,3 +7311,4 @@ Video Disk Recorder Revision History
complete GOP has been seen. This makes recordings and especially pausing live video complete GOP has been seen. This makes recordings and especially pausing live video
start up to twice as fast as before. start up to twice as fast as before.
- Updated the Romanian OSD texts (thanks to Lucian Muresan). - Updated the Romanian OSD texts (thanks to Lucian Muresan).
- Fixed handling the very last entry in a recording index.

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: recording.c 2.70 2012/11/04 15:27:44 kls Exp $ * $Id: recording.c 2.71 2012/11/12 14:48:12 kls Exp $
*/ */
#include "recording.h" #include "recording.h"
@ -1560,7 +1560,7 @@ void cIndexFileGenerator::Action(void)
uchar *p = Data; uchar *p = Data;
while (Length >= TS_SIZE) { while (Length >= TS_SIZE) {
int Pid = TsPid(p); int Pid = TsPid(p);
if (Pid == 0) if (Pid == PATPID)
PatPmtParser.ParsePat(p, TS_SIZE); PatPmtParser.ParsePat(p, TS_SIZE);
else if (Pid == PatPmtParser.PmtPid()) else if (Pid == PatPmtParser.PmtPid())
PatPmtParser.ParsePmt(p, TS_SIZE); PatPmtParser.ParsePmt(p, TS_SIZE);
@ -1768,7 +1768,7 @@ bool cIndexFile::CatchUp(int Index)
// returns true unless something really goes wrong, so that 'index' becomes NULL // returns true unless something really goes wrong, so that 'index' becomes NULL
if (index && f >= 0) { if (index && f >= 0) {
cMutexLock MutexLock(&mutex); cMutexLock MutexLock(&mutex);
for (int i = 0; i <= MAXINDEXCATCHUP && (Index < 0 || Index >= last); i++) { for (int i = 0; i <= MAXINDEXCATCHUP && (Index < 0 || Index > last); i++) {
struct stat buf; struct stat buf;
if (fstat(f, &buf) == 0) { if (fstat(f, &buf) == 0) {
if (!IsInIndexList(this)) { if (!IsInIndexList(this)) {
@ -1813,7 +1813,7 @@ bool cIndexFile::CatchUp(int Index)
} }
else else
LOG_ERROR_STR(*fileName); LOG_ERROR_STR(*fileName);
if (Index < last) if (Index <= last)
break; break;
cCondWait::SleepMs(1000); cCondWait::SleepMs(1000);
} }
@ -1841,12 +1841,13 @@ bool cIndexFile::Write(bool Independent, uint16_t FileNumber, off_t FileOffset)
bool cIndexFile::Get(int Index, uint16_t *FileNumber, off_t *FileOffset, bool *Independent, int *Length) bool cIndexFile::Get(int Index, uint16_t *FileNumber, off_t *FileOffset, bool *Independent, int *Length)
{ {
if (CatchUp(Index)) { if (CatchUp(Index)) {
if (Index >= 0 && Index < last) { if (Index >= 0 && Index <= last) {
*FileNumber = index[Index].number; *FileNumber = index[Index].number;
*FileOffset = index[Index].offset; *FileOffset = index[Index].offset;
if (Independent) if (Independent)
*Independent = index[Index].independent; *Independent = index[Index].independent;
if (Length) { if (Length) {
if (Index < last) {
uint16_t fn = index[Index + 1].number; uint16_t fn = index[Index + 1].number;
off_t fo = index[Index + 1].offset; off_t fo = index[Index + 1].offset;
if (fn == *FileNumber) if (fn == *FileNumber)
@ -1854,6 +1855,9 @@ bool cIndexFile::Get(int Index, uint16_t *FileNumber, off_t *FileOffset, bool *I
else else
*Length = -1; // this means "everything up to EOF" (the buffer's Read function will act accordingly) *Length = -1; // this means "everything up to EOF" (the buffer's Read function will act accordingly)
} }
else
*Length = -1;
}
return true; return true;
} }
} }
@ -1866,7 +1870,7 @@ int cIndexFile::GetNextIFrame(int Index, bool Forward, uint16_t *FileNumber, off
int d = Forward ? 1 : -1; int d = Forward ? 1 : -1;
for (;;) { for (;;) {
Index += d; Index += d;
if (Index >= 0 && Index < last) { if (Index >= 0 && Index <= last) {
if (index[Index].independent) { if (index[Index].independent) {
uint16_t fn; uint16_t fn;
if (!FileNumber) if (!FileNumber)
@ -1900,7 +1904,7 @@ int cIndexFile::GetNextIFrame(int Index, bool Forward, uint16_t *FileNumber, off
int cIndexFile::GetClosestIFrame(int Index) int cIndexFile::GetClosestIFrame(int Index)
{ {
if (last > 0) { if (last > 0) {
Index = constrain(Index, 0, last - 1); Index = constrain(Index, 0, last);
if (index[Index].independent) if (index[Index].independent)
return Index; return Index;
int il = Index - 1; int il = Index - 1;
@ -1911,9 +1915,9 @@ int cIndexFile::GetClosestIFrame(int Index)
return il; return il;
il--; il--;
} }
else if (ih >= last) else if (ih > last)
break; break;
if (ih < last) { if (ih <= last) {
if (index[ih].independent) if (index[ih].independent)
return ih; return ih;
ih++; ih++;
@ -1930,7 +1934,7 @@ int cIndexFile::Get(uint16_t FileNumber, off_t FileOffset)
if (CatchUp()) { if (CatchUp()) {
//TODO implement binary search! //TODO implement binary search!
int i; int i;
for (i = 0; i < last; i++) { for (i = 0; i <= last; i++) {
if (index[i].number > FileNumber || (index[i].number == FileNumber) && off_t(index[i].offset) >= FileOffset) if (index[i].number > FileNumber || (index[i].number == FileNumber) && off_t(index[i].offset) >= FileOffset)
break; break;
} }
@ -2082,7 +2086,7 @@ bool cFileName::GetLastPatPmtVersions(int &PatVersion, int &PmtVersion)
while (read(fd, buf, sizeof(buf)) == sizeof(buf)) { while (read(fd, buf, sizeof(buf)) == sizeof(buf)) {
if (buf[0] == TS_SYNC_BYTE) { if (buf[0] == TS_SYNC_BYTE) {
int Pid = TsPid(buf); int Pid = TsPid(buf);
if (Pid == 0) if (Pid == PATPID)
PatPmtParser.ParsePat(buf, sizeof(buf)); PatPmtParser.ParsePat(buf, sizeof(buf));
else if (Pid == PatPmtParser.PmtPid()) { else if (Pid == PatPmtParser.PmtPid()) {
PatPmtParser.ParsePmt(buf, sizeof(buf)); PatPmtParser.ParsePmt(buf, sizeof(buf));