mirror of
https://github.com/VDR4Arch/vdr.git
synced 2023-10-10 13:36:52 +02:00
Avoiding high CPU load in case the connection to LIRC gets lost
This commit is contained in:
parent
3d90c8c4ee
commit
2a7dd5e67d
@ -572,3 +572,6 @@ Sascha Volkenandt <sascha@akv-soft.de>
|
||||
|
||||
Malcolm Caldwell <malcolm.caldwell@ntu.edu.au>
|
||||
for modifying LOF handling to allow for C-band reception
|
||||
|
||||
Ludwig Nussel <ludwig.nussel@web.de>
|
||||
for making the LIRC thread avoid high CPU load in case the connection to LIRC gets lost
|
||||
|
2
HISTORY
2
HISTORY
@ -2012,3 +2012,5 @@ Video Disk Recorder Revision History
|
||||
(thanks to Stefan Huelswitt for reporting this one).
|
||||
- Fixed displaying messages in the status line in case they exceed the OSD width
|
||||
(thanks to Gerhard Steiner for reporting this one).
|
||||
- Avoiding high CPU load in case the connection to LIRC gets lost (thanks to
|
||||
Ludwig Nussel).
|
||||
|
17
lirc.c
17
lirc.c
@ -6,7 +6,7 @@
|
||||
*
|
||||
* LIRC support added by Carsten Koch <Carsten.Koch@icem.de> 2000-06-16.
|
||||
*
|
||||
* $Id: lirc.c 1.1 2002/09/29 13:16:33 kls Exp $
|
||||
* $Id: lirc.c 1.2 2003/04/06 15:39:48 kls Exp $
|
||||
*/
|
||||
|
||||
#include "lirc.h"
|
||||
@ -50,12 +50,22 @@ void cLircRemote::Action(void)
|
||||
char buf[LIRC_BUFFER_SIZE];
|
||||
char LastKeyName[LIRC_KEY_BUF] = "";
|
||||
bool repeat = false;
|
||||
int timeout = -1;
|
||||
|
||||
for (; f >= 0;) {
|
||||
|
||||
LOCK_THREAD;
|
||||
|
||||
if (cFile::FileReady(f, REPEATLIMIT) && safe_read(f, buf, sizeof(buf)) > 21) {
|
||||
bool ready = cFile::FileReady(f, timeout);
|
||||
int ret = ready ? safe_read(f, buf, sizeof(buf)) : -1;
|
||||
|
||||
if (ready) {
|
||||
if (ret <= 21) {
|
||||
esyslog("ERROR: lircd connection lost");
|
||||
close(f);
|
||||
f = -1;
|
||||
break;
|
||||
}
|
||||
int count;
|
||||
char KeyName[LIRC_KEY_BUF];
|
||||
sscanf(buf, "%*x %x %29s", &count, KeyName); // '29' in '%29s' is LIRC_KEY_BUF-1!
|
||||
@ -64,11 +74,13 @@ void cLircRemote::Action(void)
|
||||
strcpy(LastKeyName, KeyName);
|
||||
repeat = false;
|
||||
FirstTime = Now;
|
||||
timeout = -1;
|
||||
}
|
||||
else {
|
||||
if (Now - FirstTime < REPEATDELAY)
|
||||
continue; // repeat function kicks in after a short delay
|
||||
repeat = true;
|
||||
timeout = REPEATDELAY;
|
||||
}
|
||||
LastTime = Now;
|
||||
Put(KeyName, repeat);
|
||||
@ -78,6 +90,7 @@ void cLircRemote::Action(void)
|
||||
Put(LastKeyName, false, true);
|
||||
repeat = false;
|
||||
*LastKeyName = 0;
|
||||
timeout = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
6
tools.c
6
tools.c
@ -4,7 +4,7 @@
|
||||
* See the main source file 'vdr.c' for copyright information and
|
||||
* how to reach the author.
|
||||
*
|
||||
* $Id: tools.c 1.76 2002/11/24 20:17:31 kls Exp $
|
||||
* $Id: tools.c 1.77 2003/04/06 15:31:45 kls Exp $
|
||||
*/
|
||||
|
||||
#include "tools.h"
|
||||
@ -620,11 +620,13 @@ bool cFile::FileReady(int FileDes, int TimeoutMs)
|
||||
struct timeval timeout;
|
||||
FD_ZERO(&set);
|
||||
FD_SET(FileDes, &set);
|
||||
if (TimeoutMs >= 0) {
|
||||
if (TimeoutMs < 100)
|
||||
TimeoutMs = 100;
|
||||
timeout.tv_sec = TimeoutMs / 1000;
|
||||
timeout.tv_usec = (TimeoutMs % 1000) * 1000;
|
||||
return select(FD_SETSIZE, &set, NULL, NULL, &timeout) > 0 && FD_ISSET(FileDes, &set);
|
||||
}
|
||||
return select(FD_SETSIZE, &set, NULL, NULL, (TimeoutMs >= 0) ? &timeout : NULL) > 0 && FD_ISSET(FileDes, &set);
|
||||
}
|
||||
|
||||
bool cFile::FileReadyForWriting(int FileDes, int TimeoutMs)
|
||||
|
Loading…
Reference in New Issue
Block a user