Mercurial > mplayer.hg
comparison input/input.c @ 13345:fec54060c91f
fix a memory corruption and make sure only getch2 handles stdin
in order to avoid delayed events caused by lost input
patch by Mikulas Patocka <mikulas at artax.karlin.mff.cuni.cz>
author | faust3 |
---|---|
date | Wed, 15 Sep 2004 14:08:46 +0000 |
parents | 1c787349d286 |
children | 80fc8f48f14c |
comparison
equal
deleted
inserted
replaced
13344:0d96af97ec00 | 13345:fec54060c91f |
---|---|
659 mp_input_default_key_func(int fd) { | 659 mp_input_default_key_func(int fd) { |
660 int r,code=0; | 660 int r,code=0; |
661 unsigned int l; | 661 unsigned int l; |
662 l = 0; | 662 l = 0; |
663 while(l < sizeof(int)) { | 663 while(l < sizeof(int)) { |
664 r = read(fd,(&code)+l,sizeof(int)-l); | 664 r = read(fd,((char *)&code)+l,sizeof(int)-l); |
665 if(r <= 0) | 665 if(r <= 0) |
666 break; | 666 break; |
667 l +=r; | 667 l +=r; |
668 } | 668 } |
669 return code; | 669 return code; |
905 last_loop %= (num_key_fd+1); | 905 last_loop %= (num_key_fd+1); |
906 continue; | 906 continue; |
907 } | 907 } |
908 #ifndef HAVE_NO_POSIX_SELECT | 908 #ifndef HAVE_NO_POSIX_SELECT |
909 // No input from this fd | 909 // No input from this fd |
910 if(! (key_fds[i].flags & MP_FD_NO_SELECT) && ! FD_ISSET(key_fds[i].fd,&fds)) | 910 if(! (key_fds[i].flags & MP_FD_NO_SELECT) && ! FD_ISSET(key_fds[i].fd,&fds) && key_fds[i].fd != 0) |
911 continue; | 911 continue; |
912 #endif | 912 #endif |
913 if(key_fds[i].fd == 0) { // stdin is handled by getch2 | 913 if(key_fds[i].fd == 0) { // stdin is handled by getch2 |
914 code = getch2(time); | 914 code = getch2(time); |
915 if(code < 0) | 915 if(code < 0) |