Checking the return value of '...FileReady...' calls in dvbapi.c for better performance under heavy system load

This commit is contained in:
Klaus Schmidinger 2002-03-29 11:43:58 +01:00
parent d9b6236191
commit 0358b2abb8
2 changed files with 58 additions and 53 deletions

View File

@ -1141,3 +1141,5 @@ Video Disk Recorder Revision History
- New command command line option '-V' to display the VDR version.
- Adjusting column width for channel numbers in case there are more than 999
channels.
- Checking the return value of '...FileReady...' calls in dvbapi.c for better
performance under heavy system load.

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
* $Id: dvbapi.c 1.165 2002/03/23 16:15:00 kls Exp $
* $Id: dvbapi.c 1.166 2002/03/29 11:32:47 kls Exp $
*/
#include "dvbapi.h"
@ -525,6 +525,7 @@ void cRecordBuffer::Input(void)
time_t t = time(NULL);
recording = true;
for (;;) {
if (cFile::FileReady(videoDev, 100)) {
int r = read(videoDev, b, sizeof(b));
if (r > 0) {
uchar *p = b;
@ -545,12 +546,12 @@ void cRecordBuffer::Input(void)
}
}
}
}
if (time(NULL) - t > MAXBROKENTIMEOUT) {
esyslog(LOG_ERR, "ERROR: video data stream broken");
cThread::EmergencyExit(true);
t = time(NULL);
}
cFile::FileReady(videoDev, 100);
if (!recording)
break;
}
@ -790,7 +791,7 @@ void cPlayBuffer::Output(void)
const uchar *p = frame->Data();
int r = frame->Count();
while (r > 0 && Busy() && !blockOutput) {
cFile::FileReadyForWriting(videoDev, 100);
if (cFile::FileReadyForWriting(videoDev, 100)) {
int w = write(videoDev, p, r);
if (w > 0) {
p += w;
@ -802,6 +803,7 @@ void cPlayBuffer::Output(void)
return;
}
}
}
writeIndex = frame->Index();
backTrace.Add(frame->Index(), frame->Count());
}
@ -1370,7 +1372,7 @@ void cTransferBuffer::Input(void)
uchar b[MINVIDEODATA];
int n = 0;
while (Busy()) {
cFile::FileReady(fromDevice, 100);
if (cFile::FileReady(fromDevice, 100)) {
int r = read(fromDevice, b + n, sizeof(b) - n);
if (r > 0) {
n += r;
@ -1399,6 +1401,7 @@ void cTransferBuffer::Input(void)
}
}
}
}
dsyslog(LOG_INFO, "input thread ended (pid=%d)", getpid());
}