[MPlayer-dev-eng] [PATCH] Multi-code events get LIRC input out of sync

Reimar Döffinger Reimar.Doeffinger at stud.uni-karlsruhe.de
Sun Jan 25 19:46:52 CET 2009


On Sat, Jan 24, 2009 at 03:56:08AM +1300, Dennis Vshivkov wrote:
> attached is a patch I've been using for a few months in my
> personal MPlayer Debian package.

I have seen it, but I did and still do not like it, not being able to
use select also means that proper "sleep until input or next frame"
behaviour will not be possible.
Unfortunately there seems to be no other way to fix it, so basically
this is ok.

> @@ -21,7 +22,8 @@
>  
>  int 
>  mp_input_lirc_init(void) {
> -  int lirc_sock;
> +  int lirc_sock,
> +      mode;
>  
>    mp_msg(MSGT_LIRC,MSGL_V,MSGTR_SettingUpLIRC);
>    if((lirc_sock=lirc_init("mplayer",1))==-1){

The lirc_sock line should not be modified.

> @@ -36,12 +38,18 @@
>      return -1;
>    }
>  
> +  if ((mode = fcntl(lirc_sock, F_GETFL)) < 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;
> +  }

This is not very readable, IMO it should be
> mode = fcntl(lirc_sock, F_GETFL);
> if (mode < 0 || fcntl(lirc_sock, F_SETFL, mode | O_NONBLOCK) < 0) {
> ...


> -  fd_set fds;
> -  struct timeval tv;
>    int r,cl = 0;
>    char *code = NULL,*c = NULL;
>  
> @@ -59,21 +67,7 @@
>      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
> +  // Nothing in the buffer, poll the lirc fd

I think this means at least the
> #include <sys/types.h>
> #include <sys/time.h>
can go, also the pool -> poll fix should not be part of this patch (and
I just fixed that in SVN).

Greetings,
Reimar Döffinger



More information about the MPlayer-dev-eng mailing list