mirror of
https://github.com/VDR4Arch/vdr.git
synced 2023-10-10 13:36:52 +02:00
Fixed a crash in case the index file can't be accessed any more during replay
This commit is contained in:
parent
f2517f2c3a
commit
0f9f3f057a
@ -163,6 +163,7 @@ Stefan Huelswitt <huels@iname.com>
|
|||||||
encrypted channel
|
encrypted channel
|
||||||
for reporting a problem with timers when channel IDs have a 'source' that is 0
|
for reporting a problem with timers when channel IDs have a 'source' that is 0
|
||||||
for reporting a new/delete malloc/free mismatch in ringbuffer.c
|
for reporting a new/delete malloc/free mismatch in ringbuffer.c
|
||||||
|
for reporting a crash in case the index file can't be accessed any more during replay
|
||||||
|
|
||||||
Ulrich Röder <roeder@efr-net.de>
|
Ulrich Röder <roeder@efr-net.de>
|
||||||
for pointing out that there are channels that have a symbol rate higher than
|
for pointing out that there are channels that have a symbol rate higher than
|
||||||
|
2
HISTORY
2
HISTORY
@ -2008,3 +2008,5 @@ Video Disk Recorder Revision History
|
|||||||
Werner Fink).
|
Werner Fink).
|
||||||
- Further increased the timeout until an index file is considerd no longer to be
|
- Further increased the timeout until an index file is considerd no longer to be
|
||||||
written.
|
written.
|
||||||
|
- Fixed a crash in case the index file can't be accessed any more during replay
|
||||||
|
(thanks to Stefan Huelswitt for reporting this one).
|
||||||
|
23
recording.c
23
recording.c
@ -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 1.73 2003/03/30 13:07:03 kls Exp $
|
* $Id: recording.c 1.74 2003/03/30 13:26:20 kls Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "recording.h"
|
#include "recording.h"
|
||||||
@ -848,6 +848,7 @@ cIndexFile::~cIndexFile()
|
|||||||
|
|
||||||
bool cIndexFile::CatchUp(int Index)
|
bool cIndexFile::CatchUp(int Index)
|
||||||
{
|
{
|
||||||
|
// returns true unless something really goes wrong, so that 'index' becomes NULL
|
||||||
if (index && f >= 0) {
|
if (index && f >= 0) {
|
||||||
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;
|
||||||
@ -856,7 +857,7 @@ bool cIndexFile::CatchUp(int Index)
|
|||||||
// apparently the index file is not being written any more
|
// apparently the index file is not being written any more
|
||||||
close(f);
|
close(f);
|
||||||
f = -1;
|
f = -1;
|
||||||
return false;
|
break;
|
||||||
}
|
}
|
||||||
int newLast = buf.st_size / sizeof(tIndex) - 1;
|
int newLast = buf.st_size / sizeof(tIndex) - 1;
|
||||||
if (newLast > last) {
|
if (newLast > last) {
|
||||||
@ -889,13 +890,12 @@ bool cIndexFile::CatchUp(int Index)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
LOG_ERROR_STR(fileName);
|
LOG_ERROR_STR(fileName);
|
||||||
if (Index >= last)
|
if (Index < last)
|
||||||
sleep(1);
|
break;
|
||||||
else
|
sleep(1);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return index != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cIndexFile::Write(uchar PictureType, uchar FileNumber, int FileOffset)
|
bool cIndexFile::Write(uchar PictureType, uchar FileNumber, int FileOffset)
|
||||||
@ -915,8 +915,7 @@ bool cIndexFile::Write(uchar PictureType, uchar FileNumber, int FileOffset)
|
|||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
if (index) {
|
if (CatchUp(Index)) {
|
||||||
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;
|
||||||
@ -938,8 +937,7 @@ bool cIndexFile::Get(int Index, uchar *FileNumber, int *FileOffset, uchar *Pictu
|
|||||||
|
|
||||||
int cIndexFile::GetNextIFrame(int Index, bool Forward, uchar *FileNumber, int *FileOffset, int *Length, bool StayOffEnd)
|
int cIndexFile::GetNextIFrame(int Index, bool Forward, uchar *FileNumber, int *FileOffset, int *Length, bool StayOffEnd)
|
||||||
{
|
{
|
||||||
if (index) {
|
if (CatchUp()) {
|
||||||
CatchUp();
|
|
||||||
int d = Forward ? 1 : -1;
|
int d = Forward ? 1 : -1;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
Index += d;
|
Index += d;
|
||||||
@ -976,8 +974,7 @@ int cIndexFile::GetNextIFrame(int Index, bool Forward, uchar *FileNumber, int *F
|
|||||||
|
|
||||||
int cIndexFile::Get(uchar FileNumber, int FileOffset)
|
int cIndexFile::Get(uchar FileNumber, int FileOffset)
|
||||||
{
|
{
|
||||||
if (index) {
|
if (CatchUp()) {
|
||||||
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++) {
|
||||||
|
Loading…
Reference in New Issue
Block a user