[MPlayer-dev-eng] [PATCH] fix for mplayer input bugs: shooting to memory+lost events
Stephen Stocker
lpar at par1.net
Fri Sep 3 20:09:20 CEST 2004
Hi,
This patch was submitted by Mikulas on June 30, and I wonder if
someone could please look at it and apply if it's OK?
Its fixes a bug which occurs with SVGAlib, where if you hold down the
left arrow key to back up to the start of a video (or any key, for
that matter), then hit some other key (to change brightness, for
example), MPlayer will back up to the start of the video again.
This patch still works on current CVS, btw. Here's the URL and a copy
of the original post. Thanks!
Steve
http://mplayerhq.hu/pipermail/mplayer-users/2004-June/046528.html
--------------------------------------------------------------------------
Hi
This patch fixes two problems in mplayer input key system:
1. shooting to stack when only partial data are read from pipe (note that
when adding number to pointer, the number is multiplied by size of pointer
type).
2. delayed events on svgalib:
The problem is caused by getch2, getch2 does buffering of handle 0,
however getch2 is called only when handle 0 is reported as readable by
select.
It manifests like this:
- User holds key so that key repeat rate is higher than frame rate
(key presses are put into buffer in getch2)
- User releases key
(handle 0 is no longer reported as readable, however there are
still charactes in getch2 buffer, but getch2 is not called
anymore)
- User presses another key --- few keypresses of previous key are still
processed.
(getch2 is called and previous content of getch2 buffer is
processed)
The patch changes it so that getch2 is always called regardless of select
state of handle 0 --- it makes sense because getch2 calls select itself.
Mikulas
--- input/input.c_ 2004-06-30 02:04:43.000000000 +0100
+++ input/input.c 2004-06-30 02:25:50.000000000 +0100
@@ -656,7 +656,7 @@
unsigned int l;
l = 0;
while(l < sizeof(int)) {
- r = read(fd,(&code)+l,sizeof(int)-l);
+ r = read(fd,((char *)&code)+l,sizeof(int)-l);
if(r <= 0)
break;
l +=r;
@@ -902,7 +902,7 @@
}
#ifndef HAVE_NO_POSIX_SELECT
// No input from this fd
- if(! (key_fds[i].flags & MP_FD_NO_SELECT) && ! FD_ISSET(key_fds[i].fd,&fds))
+ if(! (key_fds[i].flags & MP_FD_NO_SELECT) && ! FD_ISSET(key_fds[i].fd,&fds) && key_fds[i].fd != 0)
continue;
#endif
if(key_fds[i].fd == 0) { // stdin is handled by getch2
--------------------------------------------------------------------------
More information about the MPlayer-dev-eng
mailing list