summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2002-03-29 11:43:58 +0100
committerKlaus Schmidinger <vdr@tvdr.de>2002-03-29 11:43:58 +0100
commit0358b2abb8478c9bf1033c6fec9ca9e302793101 (patch)
tree2a8bd1fc90007752f5a5497b61f5fb4af61baadf
parentd9b623619146914472123a635125933ca56555fe (diff)
downloadvdr-0358b2abb8478c9bf1033c6fec9ca9e302793101.tar.gz
vdr-0358b2abb8478c9bf1033c6fec9ca9e302793101.tar.bz2
Checking the return value of '...FileReady...' calls in dvbapi.c for better performance under heavy system load
-rw-r--r--HISTORY2
-rw-r--r--dvbapi.c109
2 files changed, 58 insertions, 53 deletions
diff --git a/HISTORY b/HISTORY
index 2e0aa032..dfa6286b 100644
--- a/HISTORY
+++ b/HISTORY
@@ -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.
diff --git a/dvbapi.c b/dvbapi.c
index 973ad54b..d9906189 100644
--- a/dvbapi.c
+++ b/dvbapi.c
@@ -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,23 +525,25 @@ void cRecordBuffer::Input(void)
time_t t = time(NULL);
recording = true;
for (;;) {
- int r = read(videoDev, b, sizeof(b));
- if (r > 0) {
- uchar *p = b;
- while (r > 0) {
- int w = Put(p, r);
- p += w;
- r -= w;
- }
- t = time(NULL);
- }
- else if (r < 0) {
- if (FATALERRNO) {
- if (errno == EBUFFEROVERFLOW) // this error code is not defined in the library
- esyslog(LOG_ERR, "ERROR (%s,%d): DVB driver buffer overflow", __FILE__, __LINE__);
- else {
- LOG_ERROR;
- break;
+ if (cFile::FileReady(videoDev, 100)) {
+ int r = read(videoDev, b, sizeof(b));
+ if (r > 0) {
+ uchar *p = b;
+ while (r > 0) {
+ int w = Put(p, r);
+ p += w;
+ r -= w;
+ }
+ t = time(NULL);
+ }
+ else if (r < 0) {
+ if (FATALERRNO) {
+ if (errno == EBUFFEROVERFLOW) // this error code is not defined in the library
+ esyslog(LOG_ERR, "ERROR (%s,%d): DVB driver buffer overflow", __FILE__, __LINE__);
+ else {
+ LOG_ERROR;
+ break;
+ }
}
}
}
@@ -550,7 +552,6 @@ void cRecordBuffer::Input(void)
cThread::EmergencyExit(true);
t = time(NULL);
}
- cFile::FileReady(videoDev, 100);
if (!recording)
break;
}
@@ -790,16 +791,17 @@ void cPlayBuffer::Output(void)
const uchar *p = frame->Data();
int r = frame->Count();
while (r > 0 && Busy() && !blockOutput) {
- cFile::FileReadyForWriting(videoDev, 100);
- int w = write(videoDev, p, r);
- if (w > 0) {
- p += w;
- r -= w;
- }
- else if (w < 0 && FATALERRNO) {
- LOG_ERROR;
- Stop();
- return;
+ if (cFile::FileReadyForWriting(videoDev, 100)) {
+ int w = write(videoDev, p, r);
+ if (w > 0) {
+ p += w;
+ r -= w;
+ }
+ else if (w < 0 && FATALERRNO) {
+ LOG_ERROR;
+ Stop();
+ return;
+ }
}
}
writeIndex = frame->Index();
@@ -1370,31 +1372,32 @@ void cTransferBuffer::Input(void)
uchar b[MINVIDEODATA];
int n = 0;
while (Busy()) {
- cFile::FileReady(fromDevice, 100);
- int r = read(fromDevice, b + n, sizeof(b) - n);
- if (r > 0) {
- n += r;
- int Count = n, Result;
- const uchar *p = remux.Process(b, Count, Result);
- if (p) {
- while (Result > 0 && Busy()) {
- int w = Put(p, Result);
- p += w;
- Result -= w;
- }
- }
- if (Count > 0) {
- n -= Count;
- memmove(b, b + Count, n);
+ if (cFile::FileReady(fromDevice, 100)) {
+ int r = read(fromDevice, b + n, sizeof(b) - n);
+ if (r > 0) {
+ n += r;
+ int Count = n, Result;
+ const uchar *p = remux.Process(b, Count, Result);
+ if (p) {
+ while (Result > 0 && Busy()) {
+ int w = Put(p, Result);
+ p += w;
+ Result -= w;
+ }
+ }
+ if (Count > 0) {
+ n -= Count;
+ memmove(b, b + Count, n);
+ }
}
- }
- else if (r < 0) {
- if (FATALERRNO) {
- if (errno == EBUFFEROVERFLOW) // this error code is not defined in the library
- esyslog(LOG_ERR, "ERROR (%s,%d): DVB driver buffer overflow", __FILE__, __LINE__);
- else {
- LOG_ERROR;
- break;
+ else if (r < 0) {
+ if (FATALERRNO) {
+ if (errno == EBUFFEROVERFLOW) // this error code is not defined in the library
+ esyslog(LOG_ERR, "ERROR (%s,%d): DVB driver buffer overflow", __FILE__, __LINE__);
+ else {
+ LOG_ERROR;
+ break;
+ }
}
}
}