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

Fixed breaking off replay in case the user hits "Play" or "Pause" too soon after going into "Pause live video" mode

This commit is contained in:
Klaus Schmidinger 2003-05-30 13:23:54 +02:00
parent de86dc7d01
commit 77b56da51f
3 changed files with 56 additions and 49 deletions

View File

@ -2209,7 +2209,7 @@ Video Disk Recorder Revision History
- It is now possible to directly delete a timer that is currently recording - It is now possible to directly delete a timer that is currently recording
(thanks to Alexander Damhuis for reporting this one). (thanks to Alexander Damhuis for reporting this one).
2003-05-29: Version 1.2.0pre1 2003-05-30: Version 1.2.0pre1
- Some corrections to the French OSD texts (thanks to Olivier Jacques). - Some corrections to the French OSD texts (thanks to Olivier Jacques).
- Fixed some missing commas in i18n.c (thanks to Dimitrios Dimitrakos for - Fixed some missing commas in i18n.c (thanks to Dimitrios Dimitrakos for
@ -2217,9 +2217,8 @@ Video Disk Recorder Revision History
- Some corrections to the Finnish OSD texts (thanks to Niko Tarnanen and Rolf - Some corrections to the Finnish OSD texts (thanks to Niko Tarnanen and Rolf
Ahrenberg). Ahrenberg).
- Completed the Italian OSD texts (thanks to Antonio Ospite). - Completed the Italian OSD texts (thanks to Antonio Ospite).
- Added an additional sleep() after going into "Pause live video" mode to avoid - Fixed breaking off replay in case the user hits "Play" or "Pause" too soon after
breaking off replay in case the user hits "Play" or "Pause" too soon (thanks going into "Pause live video" mode (thanks to Karim Afifi for reporting ths one).
to Karim Afifi for reporting ths one).
- Some corrections to the Catalanian OSD texts (thanks to Jordi Vilà). - Some corrections to the Catalanian OSD texts (thanks to Jordi Vilà).
- Single event timers are now deleted if the recording they are doing is - Single event timers are now deleted if the recording they are doing is
deleted before the timer ends. deleted before the timer ends.

3
menu.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: menu.c 1.252 2003/05/29 11:43:36 kls Exp $ * $Id: menu.c 1.253 2003/05/30 09:53:57 kls Exp $
*/ */
#include "menu.h" #include "menu.h"
@ -3141,7 +3141,6 @@ bool cRecordControls::PauseLiveVideo(void)
sleep(1); // allow device to replay some frames, so we have a picture sleep(1); // allow device to replay some frames, so we have a picture
Interface->Close(); Interface->Close();
rc->ProcessKey(kPause); // pause, allowing replay mode display rc->ProcessKey(kPause); // pause, allowing replay mode display
sleep(3); // allow recorded file to fill up enough to continue replaying
return true; return true;
} }
Interface->Close(); Interface->Close();

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 1.79 2003/05/24 11:22:34 kls Exp $ * $Id: recording.c 1.80 2003/05/30 13:23:54 kls Exp $
*/ */
#include "recording.h" #include "recording.h"
@ -769,6 +769,12 @@ void cRecordingUserCommand::InvokeCommand(const char *State, const char *Recordi
#define INDEXFILESUFFIX "/index.vdr" #define INDEXFILESUFFIX "/index.vdr"
// The number of frames to stay off the end in case of time shift:
#define INDEXSAFETYLIMIT 100 // frames
// The maximum time to wait before giving up while catching up on an index file:
#define MAXINDEXCATCHUP 8 // seconds
// The minimum age of an index file for considering it no longer to be written: // The minimum age of an index file for considering it no longer to be written:
#define MININDEXAGE 3600 // seconds #define MININDEXAGE 3600 // seconds
@ -852,47 +858,50 @@ 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) {
if (Index < 0 || Index >= last) { 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 (time(NULL) - buf.st_mtime > MININDEXAGE) { if (time(NULL) - buf.st_mtime > MININDEXAGE) {
// 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 true; break;
} }
int newLast = buf.st_size / sizeof(tIndex) - 1; int newLast = buf.st_size / sizeof(tIndex) - 1;
if (newLast > last) { if (newLast > last) {
if (size <= newLast) { if (size <= newLast) {
size *= 2; size *= 2;
if (size <= newLast) if (size <= newLast)
size = newLast + 1; size = newLast + 1;
} }
index = (tIndex *)realloc(index, size * sizeof(tIndex)); index = (tIndex *)realloc(index, size * sizeof(tIndex));
if (index) { if (index) {
int offset = (last + 1) * sizeof(tIndex); int offset = (last + 1) * sizeof(tIndex);
int delta = (newLast - last) * sizeof(tIndex); int delta = (newLast - last) * sizeof(tIndex);
if (lseek(f, offset, SEEK_SET) == offset) { if (lseek(f, offset, SEEK_SET) == offset) {
if (safe_read(f, &index[last + 1], delta) != delta) { if (safe_read(f, &index[last + 1], delta) != delta) {
esyslog("ERROR: can't read from index"); esyslog("ERROR: can't read from index");
free(index); free(index);
index = NULL; index = NULL;
close(f); close(f);
f = -1; f = -1;
return true; break;
} }
last = newLast; last = newLast;
} }
else else
LOG_ERROR_STR(fileName); LOG_ERROR_STR(fileName);
} }
else else
esyslog("ERROR: can't realloc() index"); esyslog("ERROR: can't realloc() index");
} }
} }
else 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;
sleep(1);
}
} }
return index != NULL; return index != NULL;
} }
@ -940,7 +949,7 @@ int cIndexFile::GetNextIFrame(int Index, bool Forward, uchar *FileNumber, int *F
int d = Forward ? 1 : -1; int d = Forward ? 1 : -1;
for (;;) { for (;;) {
Index += d; Index += d;
if (Index >= 0 && Index < last - ((Forward && StayOffEnd) ? 100 : 0)) { if (Index >= 0 && Index < last - ((Forward && StayOffEnd) ? INDEXSAFETYLIMIT : 0)) {
if (index[Index].type == I_FRAME) { if (index[Index].type == I_FRAME) {
if (FileNumber) if (FileNumber)
*FileNumber = index[Index].number; *FileNumber = index[Index].number;