PATCH: fix for lirc problems (Re: [Mplayer-users] Possible bug with lirc and Irman)

Michael Hunold M.Hunold at t-online.de
Sun Oct 7 18:54:30 CEST 2001


Hello Stephen and others,

> Reading other posts and taking a huge guess - perhaps this is a GUI
> bug.  Are you using the gui?  Others have posted that more than one
> keypress is required when using the gui so perhaps its the same bug.

No, the prob is not related to the GUI at all.

The lirc support is broken by design and I tell you why:

There is a function called "lirc_mp_getinput()" in "lirc_mp.c",
which gets called after a frame has been processed. It's purpose is
to read out one command from the queue (if possible)
and to report this as an keypress to the main process.

But that's exactly the problem: it only tries to read out
one command, but each command is terminated by a "null"
command (which should be read out, too) and
there can be more than one command in the
command queue...

The documentation of lirc clearly says, that the lirc-function
"lirc_code2char()" that read outs one command from the queue,
should be called in a loop until it reports the "null" command.

The current code does not do this and therefore each second
press get's ignored -- every second time the "null" command
is read out, which does not represent a valid key press...

A simple patch is to flush the command queue after one command
has been read out. Most of the time there is only one command
in the queue, and the flush operation will only kill the terminating
"null" command.

I attached a patch for this problem to this mail which should
be applied while being in the main mplayer directory
via

> patch -p0 < lirc.patch

> Steve

Arpi, is this ok? If so, please apply to current CVS.

CU
Michael.
-------------- next part --------------
--- lirc_mp.c.old	Sun Oct  7 13:13:35 2001
+++ lirc_mp.c	Sun Oct  7 13:37:05 2001
@@ -135,6 +135,16 @@
 
           }
         }
+	// the lirc support is "broken by design": (see mailing list discussion)
+	// we only accept one command at each call of this subroutine, but the
+	// "lirc_code2char()" function should be called in a loop
+	// until it reports "empty"... (see lirc documentation)
+	// so we need to flush the lirc command queue after we processed one
+	// command. of course we report if we really lose a message.
+        while((ret=lirc_code2char(lirc_config,code,&c))==0 && c!=NULL){
+          fprintf(stderr, "LIRC: lost command \"%s\"",c);
+	}
+	
         free(code);
         if(ret==-1){ 
            mp_msg(MSGT_LIRC,MSGL_V,"LIRC: lirc_code2char() returned an error!\n");



More information about the MPlayer-users mailing list