diff options
author | Klaus Schmidinger <vdr@tvdr.de> | 2003-04-06 15:43:41 +0200 |
---|---|---|
committer | Klaus Schmidinger <vdr@tvdr.de> | 2003-04-06 15:43:41 +0200 |
commit | 2a7dd5e67d621a2079b6bbbe47b3a4b6bba8a42b (patch) | |
tree | 5749d8661d07bac0bfc985e7b9cd3c21d87c452b /lirc.c | |
parent | 3d90c8c4ee93f69b9ce363b8430a6ef76dc9d32c (diff) | |
download | vdr-2a7dd5e67d621a2079b6bbbe47b3a4b6bba8a42b.tar.gz vdr-2a7dd5e67d621a2079b6bbbe47b3a4b6bba8a42b.tar.bz2 |
Avoiding high CPU load in case the connection to LIRC gets lost
Diffstat (limited to 'lirc.c')
-rw-r--r-- | lirc.c | 17 |
1 files changed, 15 insertions, 2 deletions
@@ -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; } } } |