summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorphintuka <phintuka>2009-08-14 11:21:54 +0000
committerphintuka <phintuka>2009-08-14 11:21:54 +0000
commit64854f0e3af3d1cb89557c078dfb085903128365 (patch)
treeb14e2a17cf641261998c24248b4bf75b0d349439
parente0cfa5effb989ec869cee9543e78e59ec5654b4a (diff)
downloadxineliboutput-unlabeled-1.10.2.tar.gz
xineliboutput-unlabeled-1.10.2.tar.bz2
Merged revisions 1.21, 1.20, 1.19unlabeled-1.10.2
Crash fix. Thanks to Antti Seppälä. Converted INTERPRET_LIRC_KEYS build-time option to runtime option. Silenced warn_unused_result warnings.
-rw-r--r--xine_frontend_lirc.c74
1 files changed, 44 insertions, 30 deletions
diff --git a/xine_frontend_lirc.c b/xine_frontend_lirc.c
index ff7aaa8e..8002cb89 100644
--- a/xine_frontend_lirc.c
+++ b/xine_frontend_lirc.c
@@ -4,7 +4,7 @@
* See the main source file 'xineliboutput.c' for copyright information and
* how to reach the author.
*
- * $Id: xine_frontend_lirc.c,v 1.10.2.2 2009-06-16 21:10:44 phintuka Exp $
+ * $Id: xine_frontend_lirc.c,v 1.10.2.3 2009-08-14 11:21:54 phintuka Exp $
*
*/
/*
@@ -32,6 +32,12 @@
#include <sys/socket.h>
#include <sys/un.h>
+#include "logdefs.h"
+
+#include "xine_frontend.h"
+#include "xine_frontend_lirc.h"
+
+
#define REPEATDELAY 350 /* ms */
#define REPEATFREQ 100 /* ms */
#define REPEATTIMEOUT 500 /* ms */
@@ -47,6 +53,9 @@ static volatile char *lirc_device_name = NULL;
static volatile int fd_lirc = -1;
static int lirc_repeat_emu = 0;
+/* xine_frontend_main.c: */
+extern int gui_hotkeys;
+
#ifndef IS_FBFE
static void sxfe_toggle_fullscreen(sxfe_t *this);
#endif
@@ -95,9 +104,9 @@ static void lircd_connect(void)
}
}
-static void *lirc_receiver_thread(void *fe)
+static void *lirc_receiver_thread(void *fe_gen)
{
- fe_t *this = (fe_t*)fe;
+ frontend_t *fe = (frontend_t*)fe_gen;
int timeout = -1;
uint64_t FirstTime = time_ms();
uint64_t LastTime = time_ms();
@@ -107,7 +116,11 @@ static void *lirc_receiver_thread(void *fe)
LOGMSG("lirc forwarding started");
- if (nice(-1) < 0) ;
+ const int priority = -1;
+ errno = 0;
+ if((nice(priority) == -1) && errno)
+ LOGDBG("LIRC: Can't nice to value: %d", priority);
+
lircd_connect();
while(lirc_device_name && fd_lirc >= 0) {
@@ -131,10 +144,10 @@ static void *lirc_receiver_thread(void *fe)
LOGMSG("LIRC connection lost ?");
break;
}
-
+
if(ready) {
- do {
+ do {
errno = 0;
ret = read(fd_lirc, buf, sizeof(buf));
pthread_testcancel();
@@ -159,7 +172,7 @@ static void *lirc_receiver_thread(void *fe)
char KeyName[LIRC_KEY_BUF];
LOGDBG("LIRC: %s", buf);
- if (sscanf(buf, "%*x %x %29s", &count, KeyName) != 2) {
+ if (sscanf(buf, "%*x %x %29s", &count, KeyName) != 2) {
/* '29' in '%29s' is LIRC_KEY_BUF-1! */
LOGMSG("unparseable lirc command: %s", buf);
continue;
@@ -170,11 +183,11 @@ static void *lirc_receiver_thread(void *fe)
count = repeat + 1;
if (count == 0) {
- if (strcmp(KeyName, LastKeyName) == 0 && elapsed(FirstTime) < REPEATDELAY)
+ if (strcmp(KeyName, LastKeyName) == 0 && elapsed(FirstTime) < REPEATDELAY)
continue; /* skip keys coming in too fast */
if (repeat) {
alarm(3);
- process_xine_keypress(this, "LIRC", LastKeyName, 0, 1);
+ process_xine_keypress((fe_t*)fe, "LIRC", LastKeyName, 0, 1);
alarm(0);
}
@@ -197,32 +210,33 @@ static void *lirc_receiver_thread(void *fe)
}
LastTime = time_ms();
-#if defined(XINELIBOUTPUT_FE_TOGGLE_FULLSCREEN) || defined(INTERPRET_LIRC_KEYS)
- if(!strcmp(KeyName, "Quit")) {
- terminate_key_pressed = 1;
- break;
-# ifndef IS_FBFE
- } else if(!strcmp(KeyName, "Fullscreen")) {
- if(!repeat)
- sxfe_toggle_fullscreen((sxfe_t*)fe);
-# endif
- } else if(!strcmp(KeyName, "Deinterlace")) {
- fe_t *this = (fe_t*)fe;
- xine_set_param(this->stream, XINE_PARAM_VO_DEINTERLACE,
- xine_get_param(this->stream, XINE_PARAM_VO_DEINTERLACE) ? 0 : 1);
- } else
+ if (gui_hotkeys) {
+ if (!strcmp(KeyName, "Quit")) {
+ terminate_key_pressed = 1;
+ break;
+ }
+#ifndef IS_FBFE
+ if (!strcmp(KeyName, "Fullscreen")) {
+ if (!repeat)
+ sxfe_toggle_fullscreen((sxfe_t*)fe);
+ continue;
+ }
#endif
- {
- alarm(3);
- process_xine_keypress(this, "LIRC", KeyName, repeat, 0);
- alarm(0);
- }
+ if (!strcmp(KeyName, "Deinterlace")) {
+ xine_set_param(((fe_t*)fe)->stream, XINE_PARAM_VO_DEINTERLACE,
+ xine_get_param(((fe_t*)fe)->stream, XINE_PARAM_VO_DEINTERLACE) ? 0 : 1);
+ }
+ }
+
+ alarm(3);
+ process_xine_keypress((fe_t*)fe, "LIRC", KeyName, repeat, 0);
+ alarm(0);
}
else if (repeat) { /* the last one was a repeat, so let's generate a release */
if (elapsed(LastTime) >= REPEATTIMEOUT) {
alarm(3);
- process_xine_keypress(this, "LIRC", LastKeyName, 0, 1);
+ process_xine_keypress((fe_t*)fe, "LIRC", LastKeyName, 0, 1);
alarm(0);
repeat = 0;
*LastKeyName = 0;
@@ -241,7 +255,7 @@ static void *lirc_receiver_thread(void *fe)
return NULL; /* never reached */
}
-void lirc_start(fe_t *fe, char *lirc_dev, int repeat_emu)
+void lirc_start(struct frontend_s *fe, char *lirc_dev, int repeat_emu)
{
if(lirc_dev) {
int err;