Mercurial > mplayer.hg
view input/lirc.c @ 27148:858c01b81117
r26502: Document rgbtest arguments
r26057: Fix copy&paste typo in rgbtest documentation
r26198: Grayscale encoding/decoding with FFmpeg is no longer enabled, remove references
r26221: Try to fix the description of what mbcmp influences, please fix if I misunderstood the code.
r26231: better syntax for A key
r26232: added missing escapes
r26260: Experimental support for -framedrop with -correct-pts.
r26271: Mention that '-frames 0' is useful with -identify, closes bug #1046.
r26273: add "ipod" to the list of formats handled by lavf
r26297: compacted new libavformat's 'ipod' description
r26402: Enable runtime control for colorful and/or module name output
r26427: Restore grayscale decoding support with FFmpeg.
r26449: 10L, forgot to commit the documentation for the -noconfig options.
r26460: restore options alphabetical order
r26650: Update documentation for the gl2 driver to make clear gl is usually preferred.
r26674: add h264 to list of supported codecs
r26732: Mark new options Michael committed as undocumented.
r26739: Oops, remove stray .TP.
r26749: -psprobe can be used in mpeg-pes streams, too
r26762: Add a new suboption to -vo xv and -vo xvmc that allows selection
r26763: Remove '(pass 1/2)' from some lavcopts. These options really worked on
r26795: Add support for AppleIR Remote as an input under Linux systems.
r26798: Document the -noar command-line option in en/fr manpages.
r26806: Document x264's AQ options
r26853: Update gl vo section with the new force-pbo suboption.
r26909: Add a slave command to stop stream playback.
r26979: small spelling/wording fixes
r26986: Document VIDIXIVTVALPHA environment variable.
r26997: Fix codec-specific options syntax declaration to be less confusing and wrong.
r27057: Ability for specifying TV standard individually for each TV channel.
r27132: Fix/restore the description of the rectangle video filter.
previously applied:
r27169: add missing escapes and full stops for scaletempo filter
r27179: remove two trailing whitespaces
author | kraymer |
---|---|
date | Mon, 30 Jun 2008 19:35:45 +0000 |
parents | 871ae3b173bd |
children | 142c53391eb7 |
line wrap: on
line source
#include "config.h" #include <lirc/lirc_client.h> #include <errno.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" #include "help_mp.h" #include "input.h" static struct lirc_config *lirc_config; char *lirc_configfile; static char* cmd_buf = NULL; int mp_input_lirc_init(void) { int lirc_sock; mp_msg(MSGT_LIRC,MSGL_V,MSGTR_SettingUpLIRC); if((lirc_sock=lirc_init("mplayer",1))==-1){ mp_msg(MSGT_LIRC,MSGL_ERR,MSGTR_LIRCopenfailed); 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); lirc_deinit(); return -1; } return lirc_sock; } 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; // We have something in the buffer return it if(cmd_buf != NULL) { int l = strlen(cmd_buf), w = l > s ? s : l; memcpy(dest,cmd_buf,w); l -= w; if(l > 0) memmove(cmd_buf,&cmd_buf[w],l+1); else { free(cmd_buf); cmd_buf = NULL; } return w; } // Nothing in the buffer, pool 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"); return MP_INPUT_DEAD; } if(!code) return MP_INPUT_NOTHING; // We put all cmds in a single buffer separated by \n while((r = lirc_code2char(lirc_config,code,&c))==0 && c!=NULL) { int l = strlen(c); if(l <= 0) continue; cmd_buf = realloc(cmd_buf,cl+l+2); memcpy(&cmd_buf[cl],c,l); cl += l+1; cmd_buf[cl-1] = '\n'; cmd_buf[cl] = '\0'; } free(code); if(r < 0) return MP_INPUT_DEAD; else if(cmd_buf) // return the first command in the buffer return mp_input_lirc_read(fd,dest,s); else return MP_INPUT_RETRY; } void mp_input_lirc_close(int fd) { if(cmd_buf) { free(cmd_buf); cmd_buf = NULL; } lirc_freeconfig(lirc_config); lirc_deinit(); }