rendered paste bodydiff -Nur MPlayer-1.0rc1.old/Makefile MPlayer-1.0rc1.new/Makefile
--- MPlayer-1.0rc1.old/Makefile 2006-10-23 00:32:31.000000000 +0200
+++ MPlayer-1.0rc1.new/Makefile 2006-10-26 00:40:20.000000000 +0200
@@ -410,6 +410,7 @@
$(CC) -DCODECS2HTML codec-cfg.c mp_msg.o -o $@
install: $(ALL_PRG)
+ $(MAKE) -C input install
ifeq ($(VIDIX),yes)
$(MAKE) -C libdha install
$(MAKE) -C vidix install
diff -Nur MPlayer-1.0rc1.old/configure MPlayer-1.0rc1.new/configure
--- MPlayer-1.0rc1.old/configure 2006-10-23 00:32:31.000000000 +0200
+++ MPlayer-1.0rc1.new/configure 2006-10-26 00:40:20.000000000 +0200
@@ -7382,7 +7382,7 @@
fi
if test "$_lirc" = yes ; then
_def_lirc='#define HAVE_LIRC 1'
- _ld_lirc='-llirc_client'
+ #_ld_lirc='-llirc_client'
else
_def_lirc='#undef HAVE_LIRC'
fi
diff -Nur MPlayer-1.0rc1.old/input/Makefile MPlayer-1.0rc1.new/input/Makefile
--- MPlayer-1.0rc1.old/input/Makefile 2006-10-23 00:32:25.000000000 +0200
+++ MPlayer-1.0rc1.new/input/Makefile 2006-10-26 00:58:46.000000000 +0200
@@ -2,6 +2,7 @@
include ../config.mak
LIBNAME = libinput.a
+LIBSRCS =
SRCS=input.c
ifeq ($(JOYSTICK),yes)
@@ -9,26 +10,31 @@
endif
ifeq ($(LIRC),yes)
SRCS += lirc.c
+LIBSRCS += lirc-dl.c
endif
OBJS=$(SRCS:.c=.o)
+SHAREDOBJS=$(LIBSRCS:.c=.so)
CFLAGS = -I. -I.. $(OPTFLAGS)
-.SUFFIXES: .c .o
+.SUFFIXES: .c .o .so
.c.o:
$(CC) -c $(CFLAGS) -o $@ $<
+all: $(LIBNAME) $(SHAREDOBJS)
+
$(LIBNAME): $(OBJS)
$(AR) r $(LIBNAME) $(OBJS)
$(RANLIB) $(LIBNAME)
-all: $(LIBNAME)
+lirc-dl.so: lirc-dl.c lirc-dl.h
+ $(CC) $(CFLAGS) -llirc_client -shared -o $@ $<
clean:
- rm -f *.o *.a *~
+ rm -f *.o *.a *.so *~
distclean: clean
rm -f .depend
@@ -38,6 +44,10 @@
depend:
$(CC) -MM $(CFLAGS) $(SRCS) 1>.depend
+install:
+ $(INSTALL) -d $(LIBDIR)/mplayer
+ $(INSTALL) -m 755 $(INSTALLSTRIP) -p *.so $(LIBDIR)/mplayer
+
#
# include dependency files if they exist
#
diff -Nur MPlayer-1.0rc1.old/input/lirc-dl.c MPlayer-1.0rc1.new/input/lirc-dl.c
--- MPlayer-1.0rc1.old/input/lirc-dl.c 1970-01-01 01:00:00.000000000 +0100
+++ MPlayer-1.0rc1.new/input/lirc-dl.c 2006-10-26 00:51:48.000000000 +0200
@@ -0,0 +1,122 @@
+
+#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 "lirc-dl.h"
+#include "mp_msg.h"
+#include "help_mp.h"
+#include "input.h"
+
+static struct lirc_config *lirc_config;
+extern char *lirc_configfile;
+
+static char* cmd_buf = NULL;
+
+int
+mp_input_lirc_dl_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_dl_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_dl_close(int fd) {
+ if(cmd_buf) {
+ free(cmd_buf);
+ cmd_buf = NULL;
+ }
+ lirc_freeconfig(lirc_config);
+ lirc_deinit();
+}
+
+struct mp_input_lirc_functions lirc_dl_functions = {
+ .init = &mp_input_lirc_dl_init,
+ .read = &mp_input_lirc_dl_read,
+ .close = &mp_input_lirc_dl_close
+};
diff -Nur MPlayer-1.0rc1.old/input/lirc-dl.h MPlayer-1.0rc1.new/input/lirc-dl.h
--- MPlayer-1.0rc1.old/input/lirc-dl.h 1970-01-01 01:00:00.000000000 +0100
+++ MPlayer-1.0rc1.new/input/lirc-dl.h 2006-10-26 00:40:20.000000000 +0200
@@ -0,0 +1,5 @@
+struct mp_input_lirc_functions {
+ int (*init)(void);
+ int (*read)(int, char*, int);
+ void (*close)(int);
+};
diff -Nur MPlayer-1.0rc1.old/input/lirc.c MPlayer-1.0rc1.new/input/lirc.c
--- MPlayer-1.0rc1.old/input/lirc.c 2006-10-23 00:32:25.000000000 +0200
+++ MPlayer-1.0rc1.new/input/lirc.c 2006-10-26 00:52:01.000000000 +0200
@@ -1,115 +1,46 @@
-
#include "config.h"
+#include "lirc-dl.h"
+#include "input.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 <dlfcn.h>
#include <stdlib.h>
-#include "mp_msg.h"
-#include "help_mp.h"
-#include "input.h"
-
-static struct lirc_config *lirc_config;
+static struct mp_input_lirc_functions *functions;
+static void *lirc_handle;
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;
+int mp_input_lirc_init(void)
+{
+ if(functions==NULL)
+ {
+ lirc_handle = dlopen(MPLAYER_LIBDIR "/mplayer/lirc-dl.so", RTLD_LAZY);
+ if(lirc_handle==NULL)
+ return 0;
+ functions = dlsym(lirc_handle, "lirc_dl_functions");
+ if(functions==NULL)
+ return 0;
}
-
- 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;
+ if(functions->init!=NULL)
+ return (*functions->init)();
+ else
+ return 0;
}
-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);
+int mp_input_lirc_read(int fd, char* dest, int s)
+{
+ if(functions!=NULL && functions->read!=NULL)
+ return (*functions->read)(fd, dest, s);
else
- return MP_INPUT_RETRY;
-
+ return MP_INPUT_DEAD;
}
-void
-mp_input_lirc_close(int fd) {
- if(cmd_buf) {
- free(cmd_buf);
- cmd_buf = NULL;
+void mp_input_lirc_close(int fd) {
+ if(functions!=NULL && functions->close!=NULL)
+ {
+ (*functions->close)(fd);
+ if(lirc_handle!=NULL)
+ dlclose(lirc_handle);
+ lirc_handle=NULL;
+ functions=NULL;
}
- lirc_freeconfig(lirc_config);
- lirc_deinit();
}
diff -Nur MPlayer-1.0rc1.old/input/lirc.h MPlayer-1.0rc1.new/input/lirc.h
--- MPlayer-1.0rc1.old/input/lirc.h 2006-10-23 00:32:25.000000000 +0200
+++ MPlayer-1.0rc1.new/input/lirc.h 2006-10-26 00:40:20.000000000 +0200
@@ -1,6 +1,6 @@
-int
+int
mp_input_lirc_init(void);
int