summaryrefslogtreecommitdiffstats
path: root/input
diff options
context:
space:
mode:
authorUoti Urpala <uau@glyph.nonexistent.invalid>2009-01-31 04:52:15 +0200
committerUoti Urpala <uau@glyph.nonexistent.invalid>2009-01-31 04:52:15 +0200
commitccf4d9e96cd7aa8506e6632d2a7352ec89b2b9e3 (patch)
treea5f3a6d636e96f05bb52f0b2407107a7f0c8b443 /input
parent03aa64687fc109c5f2346a3c191b70698b333509 (diff)
parent0e77da241da8b911c96a0e22898e84d7f7b74678 (diff)
downloadmpv-ccf4d9e96cd7aa8506e6632d2a7352ec89b2b9e3.tar.bz2
mpv-ccf4d9e96cd7aa8506e6632d2a7352ec89b2b9e3.tar.xz
Merge svn changes up to r28403
Diffstat (limited to 'input')
-rw-r--r--input/lirc.c30
1 files changed, 11 insertions, 19 deletions
diff --git a/input/lirc.c b/input/lirc.c
index 4012d5b340..4e60f01182 100644
--- a/input/lirc.c
+++ b/input/lirc.c
@@ -20,11 +20,10 @@
#include <lirc/lirc_client.h>
#include <errno.h>
+#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
-#include <sys/types.h>
-#include <sys/time.h>
#include <stdlib.h>
#include "mp_msg.h"
@@ -39,6 +38,7 @@ static char* cmd_buf = NULL;
int
mp_input_lirc_init(void) {
int lirc_sock;
+ int mode;
mp_msg(MSGT_LIRC,MSGL_V,MSGTR_SettingUpLIRC);
if((lirc_sock=lirc_init("mplayer",1))==-1){
@@ -46,6 +46,14 @@ mp_input_lirc_init(void) {
return -1;
}
+ mode = fcntl(lirc_sock, F_GETFL);
+ if (mode < 0 || fcntl(lirc_sock, F_SETFL, mode | O_NONBLOCK) < 0) {
+ mp_msg(MSGT_LIRC, MSGL_ERR, "setting non-blocking mode failed: %s\n",
+ strerror(errno));
+ lirc_deinit();
+ return -1;
+ }
+
if(lirc_readconfig( lirc_configfile,&lirc_config,NULL )!=0 ){
mp_msg(MSGT_LIRC,MSGL_ERR,MSGTR_LIRCcfgerr,
lirc_configfile == NULL ? "~/.lircrc" : lirc_configfile);
@@ -57,8 +65,6 @@ mp_input_lirc_init(void) {
}
int mp_input_lirc_read(int fd,char* dest, int s) {
- fd_set fds;
- struct timeval tv;
int r,cl = 0;
char *code = NULL,*c = NULL;
@@ -77,22 +83,8 @@ int mp_input_lirc_read(int fd,char* dest, int s) {
}
// Nothing in the buffer, poll the lirc fd
- FD_ZERO(&fds);
- FD_SET(fd,&fds);
- memset(&tv,0,sizeof(tv));
- while((r = select(fd+1,&fds,NULL,NULL,&tv)) <= 0) {
- if(r < 0) {
- if(errno == EINTR)
- continue;
- mp_msg(MSGT_INPUT,MSGL_ERR,"Select error : %s\n",strerror(errno));
- return MP_INPUT_ERROR;
- } else
- return MP_INPUT_NOTHING;
- }
-
- // There's something to read
if(lirc_nextcode(&code) != 0) {
- mp_msg(MSGT_INPUT,MSGL_ERR,"Lirc error :(\n");
+ mp_msg(MSGT_LIRC,MSGL_ERR,"Lirc error :(\n");
return MP_INPUT_DEAD;
}