[MPlayer-dev-eng] [PATCH] selectus interruptus

Artur Skawina skawina at geocities.com
Mon Nov 19 22:04:51 CET 2001


while trying a build w/ profiling enabled i got bitten by
a few assumptions that the select() will never be interrupted.
[which happens here within seconds by the profiling timer,
and results in mplayer blocking indefinitely on eg the read
call in getch2()...]

patch attached.

btw, the Gui/Makefile and Gui/mplayer/Makefile files contain
redundant $OPTIMIZE flags (specifically '-fomit-frame-pointer',
which doesn't work all that well with '-pg'... I simply killed
those here, but i suspect more of the options could be moved
out)

artur
-------------- next part --------------
diff -urNp main/fifo.c main-as/fifo.c
--- main/fifo.c	Fri Mar 16 01:06:50 2001
+++ main-as/fifo.c	Mon Nov 19 20:42:11 2001
@@ -51,7 +51,7 @@ void mplayer_put_key(int code){
            tv.tv_usec = 0;
 
            //retval = select(keyb_fifo_put+1, &rfds, NULL, NULL, &tv);
-           if(select(keyb_fifo_put+1, NULL, &rfds, NULL, &tv)){
+           if(select(keyb_fifo_put+1, NULL, &rfds, NULL, &tv)>0){
              write(keyb_fifo_put,&code,4);
 //             printf("*** key event %d sent ***\n",code);
            } else {
@@ -71,7 +71,7 @@ int mplayer_get_key(){
            tv.tv_usec = 0;
 
            //retval = select(keyb_fifo_put+1, &rfds, NULL, NULL, &tv);
-           if(select(keyb_fifo_put+1, &rfds, NULL, NULL, &tv)){
+           if(select(keyb_fifo_put+1, &rfds, NULL, NULL, &tv)>0){
              read(keyb_fifo_get,&code,4);
 //             printf("*** key event %d read ***\n",code);
            }
diff -urNp main/linux/getch2.c main-as/linux/getch2.c
--- main/linux/getch2.c	Mon Nov 19 20:32:15 2001
+++ main-as/linux/getch2.c	Mon Nov 19 20:42:11 2001
@@ -130,7 +130,7 @@ int getch2(int time){
     /* Wait up to 'time' microseconds. */
     tv.tv_sec=time/1000; tv.tv_usec = (time%1000)*1000;
     retval=select(1, &rfds, NULL, NULL, &tv);
-    if(!retval) return -1;
+    if(retval<=0) return -1;
     /* Data is available now. */
     retval=read(0,&getch2_buf[getch2_len],BUF_LEN-getch2_len);
     if(retval<1) return -1;


More information about the MPlayer-dev-eng mailing list