mirror of
https://github.com/VDR4Arch/vdr.git
synced 2023-10-10 13:36:52 +02:00
Checking the return value of '...FileReady...' calls in dvbapi.c for better performance under heavy system load
This commit is contained in:
parent
d9b6236191
commit
0358b2abb8
2
HISTORY
2
HISTORY
@ -1141,3 +1141,5 @@ Video Disk Recorder Revision History
|
|||||||
- New command command line option '-V' to display the VDR version.
|
- New command command line option '-V' to display the VDR version.
|
||||||
- Adjusting column width for channel numbers in case there are more than 999
|
- Adjusting column width for channel numbers in case there are more than 999
|
||||||
channels.
|
channels.
|
||||||
|
- Checking the return value of '...FileReady...' calls in dvbapi.c for better
|
||||||
|
performance under heavy system load.
|
||||||
|
109
dvbapi.c
109
dvbapi.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: 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"
|
#include "dvbapi.h"
|
||||||
@ -525,23 +525,25 @@ void cRecordBuffer::Input(void)
|
|||||||
time_t t = time(NULL);
|
time_t t = time(NULL);
|
||||||
recording = true;
|
recording = true;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
int r = read(videoDev, b, sizeof(b));
|
if (cFile::FileReady(videoDev, 100)) {
|
||||||
if (r > 0) {
|
int r = read(videoDev, b, sizeof(b));
|
||||||
uchar *p = b;
|
if (r > 0) {
|
||||||
while (r > 0) {
|
uchar *p = b;
|
||||||
int w = Put(p, r);
|
while (r > 0) {
|
||||||
p += w;
|
int w = Put(p, r);
|
||||||
r -= w;
|
p += w;
|
||||||
}
|
r -= w;
|
||||||
t = time(NULL);
|
}
|
||||||
}
|
t = time(NULL);
|
||||||
else if (r < 0) {
|
}
|
||||||
if (FATALERRNO) {
|
else if (r < 0) {
|
||||||
if (errno == EBUFFEROVERFLOW) // this error code is not defined in the library
|
if (FATALERRNO) {
|
||||||
esyslog(LOG_ERR, "ERROR (%s,%d): DVB driver buffer overflow", __FILE__, __LINE__);
|
if (errno == EBUFFEROVERFLOW) // this error code is not defined in the library
|
||||||
else {
|
esyslog(LOG_ERR, "ERROR (%s,%d): DVB driver buffer overflow", __FILE__, __LINE__);
|
||||||
LOG_ERROR;
|
else {
|
||||||
break;
|
LOG_ERROR;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -550,7 +552,6 @@ void cRecordBuffer::Input(void)
|
|||||||
cThread::EmergencyExit(true);
|
cThread::EmergencyExit(true);
|
||||||
t = time(NULL);
|
t = time(NULL);
|
||||||
}
|
}
|
||||||
cFile::FileReady(videoDev, 100);
|
|
||||||
if (!recording)
|
if (!recording)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -790,16 +791,17 @@ void cPlayBuffer::Output(void)
|
|||||||
const uchar *p = frame->Data();
|
const uchar *p = frame->Data();
|
||||||
int r = frame->Count();
|
int r = frame->Count();
|
||||||
while (r > 0 && Busy() && !blockOutput) {
|
while (r > 0 && Busy() && !blockOutput) {
|
||||||
cFile::FileReadyForWriting(videoDev, 100);
|
if (cFile::FileReadyForWriting(videoDev, 100)) {
|
||||||
int w = write(videoDev, p, r);
|
int w = write(videoDev, p, r);
|
||||||
if (w > 0) {
|
if (w > 0) {
|
||||||
p += w;
|
p += w;
|
||||||
r -= w;
|
r -= w;
|
||||||
}
|
}
|
||||||
else if (w < 0 && FATALERRNO) {
|
else if (w < 0 && FATALERRNO) {
|
||||||
LOG_ERROR;
|
LOG_ERROR;
|
||||||
Stop();
|
Stop();
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
writeIndex = frame->Index();
|
writeIndex = frame->Index();
|
||||||
@ -1370,31 +1372,32 @@ void cTransferBuffer::Input(void)
|
|||||||
uchar b[MINVIDEODATA];
|
uchar b[MINVIDEODATA];
|
||||||
int n = 0;
|
int n = 0;
|
||||||
while (Busy()) {
|
while (Busy()) {
|
||||||
cFile::FileReady(fromDevice, 100);
|
if (cFile::FileReady(fromDevice, 100)) {
|
||||||
int r = read(fromDevice, b + n, sizeof(b) - n);
|
int r = read(fromDevice, b + n, sizeof(b) - n);
|
||||||
if (r > 0) {
|
if (r > 0) {
|
||||||
n += r;
|
n += r;
|
||||||
int Count = n, Result;
|
int Count = n, Result;
|
||||||
const uchar *p = remux.Process(b, Count, Result);
|
const uchar *p = remux.Process(b, Count, Result);
|
||||||
if (p) {
|
if (p) {
|
||||||
while (Result > 0 && Busy()) {
|
while (Result > 0 && Busy()) {
|
||||||
int w = Put(p, Result);
|
int w = Put(p, Result);
|
||||||
p += w;
|
p += w;
|
||||||
Result -= 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;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user