diff options
author | wm4 <wm4@nowhere> | 2012-11-05 17:02:04 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2012-11-12 20:06:14 +0100 |
commit | d4bdd0473d6f43132257c9fb3848d829755167a3 (patch) | |
tree | 8021c2f7da1841393c8c832105e20cd527826d6c /input/lirc.c | |
parent | bd48deba77bd5582c5829d6fe73a7d2571088aba (diff) | |
download | mpv-d4bdd0473d6f43132257c9fb3848d829755167a3.tar.bz2 mpv-d4bdd0473d6f43132257c9fb3848d829755167a3.tar.xz |
Rename directories, move files (step 1 of 2) (does not compile)
Tis drops the silly lib prefixes, and attempts to organize the tree in
a more logical way. Make the top-level directory less cluttered as
well.
Renames the following directories:
libaf -> audio/filter
libao2 -> audio/out
libvo -> video/out
libmpdemux -> demux
Split libmpcodecs:
vf* -> video/filter
vd*, dec_video.* -> video/decode
mp_image*, img_format*, ... -> video/
ad*, dec_audio.* -> audio/decode
libaf/format.* is moved to audio/ - this is similar to how mp_image.*
is located in video/.
Move most top-level .c/.h files to core. (talloc.c/.h is left on top-
level, because it's external.) Park some of the more annoying files
in compat/. Some of these are relicts from the time mplayer used
ffmpeg internals.
sub/ is not split, because it's too much of a mess (subtitle code is
mixed with OSD display and rendering).
Maybe the organization of core is not ideal: it mixes playback core
(like mplayer.c) and utility helpers (like bstr.c/h). Should the need
arise, the playback core will be moved somewhere else, while core
contains all helper and common code.
Diffstat (limited to 'input/lirc.c')
-rw-r--r-- | input/lirc.c | 123 |
1 files changed, 0 insertions, 123 deletions
diff --git a/input/lirc.c b/input/lirc.c deleted file mode 100644 index fd64beb479..0000000000 --- a/input/lirc.c +++ /dev/null @@ -1,123 +0,0 @@ -/* - * This file is part of MPlayer. - * - * MPlayer is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * MPlayer is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with MPlayer; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include "config.h" - -#include <lirc/lirc_client.h> -#include <errno.h> -#include <fcntl.h> -#include <stdio.h> -#include <string.h> -#include <unistd.h> -#include <stdlib.h> - -#include "mp_msg.h" -#include "input.h" -#include "lirc.h" - -static struct lirc_config *lirc_config; -char *lirc_configfile; - -static char* cmd_buf = NULL; - -int -mp_input_lirc_init(void) { - int lirc_sock; - int mode; - - mp_tmsg(MSGT_LIRC,MSGL_V,"Setting up LIRC support...\n"); - if((lirc_sock=lirc_init("mpv",0))==-1){ - mp_tmsg(MSGT_LIRC,MSGL_V,"Failed to open LIRC support. You will not be able to use your remote control.\n"); - 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_tmsg(MSGT_LIRC,MSGL_ERR,"Failed to read LIRC config file %s.\n", - lirc_configfile == NULL ? "~/.lircrc" : lirc_configfile); - lirc_deinit(); - return -1; - } - - return lirc_sock; -} - -int mp_input_lirc_read(int fd,char* dest, int s) { - 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, poll the lirc fd - if(lirc_nextcode(&code) != 0) { - mp_msg(MSGT_LIRC,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; - -} - -int mp_input_lirc_close(int fd) -{ - free(cmd_buf); - cmd_buf = NULL; - lirc_freeconfig(lirc_config); - lirc_deinit(); - return 0; -} |