mirror of
https://github.com/VDR4Arch/vdr.git
synced 2023-10-10 13:36:52 +02:00
Some missed places where cThread::Running() should be used
This commit is contained in:
parent
69c17e7101
commit
01ea9d7b0d
84
lirc.c
84
lirc.c
@ -6,7 +6,7 @@
|
|||||||
*
|
*
|
||||||
* LIRC support added by Carsten Koch <Carsten.Koch@icem.de> 2000-06-16.
|
* LIRC support added by Carsten Koch <Carsten.Koch@icem.de> 2000-06-16.
|
||||||
*
|
*
|
||||||
* $Id: lirc.c 1.11 2005/07/31 10:18:09 kls Exp $
|
* $Id: lirc.c 1.12 2005/08/15 12:28:10 kls Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "lirc.h"
|
#include "lirc.h"
|
||||||
@ -61,48 +61,48 @@ void cLircRemote::Action(void)
|
|||||||
bool repeat = false;
|
bool repeat = false;
|
||||||
int timeout = -1;
|
int timeout = -1;
|
||||||
|
|
||||||
for (; f >= 0;) {
|
while (Running() && f >= 0) {
|
||||||
|
|
||||||
bool ready = cFile::FileReady(f, timeout);
|
bool ready = cFile::FileReady(f, timeout);
|
||||||
int ret = ready ? safe_read(f, buf, sizeof(buf)) : -1;
|
int ret = ready ? safe_read(f, buf, sizeof(buf)) : -1;
|
||||||
|
|
||||||
if (ready && ret <= 0 ) {
|
if (ready && ret <= 0 ) {
|
||||||
esyslog("ERROR: lircd connection lost");
|
esyslog("ERROR: lircd connection lost");
|
||||||
close(f);
|
close(f);
|
||||||
f = -1;
|
f = -1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ready && ret > 21) {
|
if (ready && ret > 21) {
|
||||||
int count;
|
int count;
|
||||||
char KeyName[LIRC_KEY_BUF];
|
char KeyName[LIRC_KEY_BUF];
|
||||||
sscanf(buf, "%*x %x %29s", &count, KeyName); // '29' in '%29s' is LIRC_KEY_BUF-1!
|
sscanf(buf, "%*x %x %29s", &count, KeyName); // '29' in '%29s' is LIRC_KEY_BUF-1!
|
||||||
if (count == 0) {
|
if (count == 0) {
|
||||||
if (strcmp(KeyName, LastKeyName) == 0 && FirstTime.Elapsed() < KEYPRESSDELAY)
|
if (strcmp(KeyName, LastKeyName) == 0 && FirstTime.Elapsed() < KEYPRESSDELAY)
|
||||||
continue; // skip keys coming in too fast
|
continue; // skip keys coming in too fast
|
||||||
if (repeat)
|
if (repeat)
|
||||||
Put(LastKeyName, false, true);
|
Put(LastKeyName, false, true);
|
||||||
strcpy(LastKeyName, KeyName);
|
strcpy(LastKeyName, KeyName);
|
||||||
repeat = false;
|
repeat = false;
|
||||||
FirstTime.Set();
|
FirstTime.Set();
|
||||||
timeout = -1;
|
timeout = -1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (FirstTime.Elapsed() < REPEATDELAY)
|
if (FirstTime.Elapsed() < REPEATDELAY)
|
||||||
continue; // repeat function kicks in after a short delay
|
continue; // repeat function kicks in after a short delay
|
||||||
repeat = true;
|
repeat = true;
|
||||||
timeout = REPEATDELAY;
|
timeout = REPEATDELAY;
|
||||||
}
|
}
|
||||||
LastTime.Set();
|
LastTime.Set();
|
||||||
Put(KeyName, repeat);
|
Put(KeyName, repeat);
|
||||||
}
|
}
|
||||||
else if (repeat) { // the last one was a repeat, so let's generate a release
|
else if (repeat) { // the last one was a repeat, so let's generate a release
|
||||||
if (LastTime.Elapsed() >= REPEATDELAY) {
|
if (LastTime.Elapsed() >= REPEATDELAY) {
|
||||||
Put(LastKeyName, false, true);
|
Put(LastKeyName, false, true);
|
||||||
repeat = false;
|
repeat = false;
|
||||||
*LastKeyName = 0;
|
*LastKeyName = 0;
|
||||||
timeout = -1;
|
timeout = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
105
rcu.c
105
rcu.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: rcu.c 1.9 2005/07/31 10:17:45 kls Exp $
|
* $Id: rcu.c 1.10 2005/08/15 12:30:21 kls Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "rcu.h"
|
#include "rcu.h"
|
||||||
@ -98,60 +98,59 @@ void cRcuRemote::Action(void)
|
|||||||
uint64 LastCommand = 0;
|
uint64 LastCommand = 0;
|
||||||
bool repeat = false;
|
bool repeat = false;
|
||||||
|
|
||||||
//XXX
|
while (Running() && f >= 0) {
|
||||||
for (; f >= 0;) {
|
|
||||||
|
|
||||||
LOCK_THREAD;
|
LOCK_THREAD;
|
||||||
|
|
||||||
if (ReceiveByte(REPEATLIMIT) == 'X') {
|
if (ReceiveByte(REPEATLIMIT) == 'X') {
|
||||||
for (int i = 0; i < 6; i++) {
|
for (int i = 0; i < 6; i++) {
|
||||||
int b = ReceiveByte();
|
int b = ReceiveByte();
|
||||||
if (b >= 0) {
|
if (b >= 0) {
|
||||||
buffer.raw[i] = b;
|
buffer.raw[i] = b;
|
||||||
if (i == 5) {
|
if (i == 5) {
|
||||||
unsigned short Address = ntohs(buffer.data.address); // the PIC sends bytes in "network order"
|
unsigned short Address = ntohs(buffer.data.address); // the PIC sends bytes in "network order"
|
||||||
uint64 Command = ntohl(buffer.data.command);
|
uint64 Command = ntohl(buffer.data.command);
|
||||||
if (code == 'B' && Address == 0x0000 && Command == 0x00004000)
|
if (code == 'B' && Address == 0x0000 && Command == 0x00004000)
|
||||||
// Well, well, if it isn't the "d-box"...
|
// Well, well, if it isn't the "d-box"...
|
||||||
// This remote control sends the above command before and after
|
// This remote control sends the above command before and after
|
||||||
// each keypress - let's just drop this:
|
// each keypress - let's just drop this:
|
||||||
break;
|
break;
|
||||||
Command |= uint64(Address) << 32;
|
Command |= uint64(Address) << 32;
|
||||||
if (Command != LastCommand) {
|
if (Command != LastCommand) {
|
||||||
LastCommand = Command;
|
LastCommand = Command;
|
||||||
repeat = false;
|
repeat = false;
|
||||||
FirstTime.Set();
|
FirstTime.Set();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (FirstTime.Elapsed() < REPEATDELAY)
|
if (FirstTime.Elapsed() < REPEATDELAY)
|
||||||
break; // repeat function kicks in after a short delay
|
break; // repeat function kicks in after a short delay
|
||||||
repeat = true;
|
repeat = true;
|
||||||
}
|
}
|
||||||
Put(Command, repeat);
|
Put(Command, repeat);
|
||||||
receivedCommand = true;
|
receivedCommand = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (repeat) { // the last one was a repeat, so let's generate a release
|
else if (repeat) { // the last one was a repeat, so let's generate a release
|
||||||
Put(LastCommand, false, true);
|
Put(LastCommand, false, true);
|
||||||
repeat = false;
|
repeat = false;
|
||||||
LastCommand = 0;
|
LastCommand = 0;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
LastCommand = 0;
|
LastCommand = 0;
|
||||||
if (numberToSend >= 0) {
|
if (numberToSend >= 0) {
|
||||||
Number(numberToSend);
|
Number(numberToSend);
|
||||||
numberToSend = -1;
|
numberToSend = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (code && time(NULL) - LastCodeRefresh > 60) {
|
if (code && time(NULL) - LastCodeRefresh > 60) {
|
||||||
SendCommand(code); // in case the PIC listens to the wrong code
|
SendCommand(code); // in case the PIC listens to the wrong code
|
||||||
LastCodeRefresh = time(NULL);
|
LastCodeRefresh = time(NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int cRcuRemote::ReceiveByte(int TimeoutMs)
|
int cRcuRemote::ReceiveByte(int TimeoutMs)
|
||||||
|
Loading…
Reference in New Issue
Block a user