summaryrefslogtreecommitdiffstats
path: root/fifo.c
diff options
context:
space:
mode:
authorreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>2007-02-05 17:51:26 +0000
committerreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>2007-02-05 17:51:26 +0000
commit0944709a29b02ffaa8e83140dbd0388d5e152f8f (patch)
tree30959f588153568fdc9083aa12c7c2c51e3e6dbe /fifo.c
parent3baddb9645a6b0af4a22bc0d60554cf91fa903df (diff)
downloadmpv-0944709a29b02ffaa8e83140dbd0388d5e152f8f.tar.bz2
mpv-0944709a29b02ffaa8e83140dbd0388d5e152f8f.tar.xz
Reserve half of fifo for key release events to help avoiding stop buttons
and remove thus useless hack for mouse wheel. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@22149 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'fifo.c')
-rw-r--r--fifo.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/fifo.c b/fifo.c
index bd9afc54b7..e43f0649e3 100644
--- a/fifo.c
+++ b/fifo.c
@@ -35,16 +35,21 @@ static void mplayer_put_key_internal(int code){
#else
-int key_fifo_size = 10;
+int key_fifo_size = 7;
static int *key_fifo_data = NULL;
static int key_fifo_read=0;
static int key_fifo_write=0;
static void mplayer_put_key_internal(int code){
+ int fifo_free = key_fifo_read - key_fifo_write - 1;
+ if (fifo_free < 0) fifo_free += key_fifo_size;
// printf("mplayer_put_key(%d)\n",code);
if (key_fifo_data == NULL)
key_fifo_data = malloc(key_fifo_size * sizeof(int));
- if(((key_fifo_write+1)%key_fifo_size)==key_fifo_read) return; // FIFO FULL!!
+ if(!fifo_free) return; // FIFO FULL!!
+ // reserve some space for key release events to avoid stuck keys
+ if((code & MP_KEY_DOWN) && fifo_free < (key_fifo_size >> 1))
+ return;
key_fifo_data[key_fifo_write]=code;
key_fifo_write=(key_fifo_write+1)%key_fifo_size;
}
@@ -79,8 +84,6 @@ void mplayer_put_key(int code) {
(code & ~MP_KEY_DOWN) >= MOUSE_BTN0_DBL &&
(code & ~MP_KEY_DOWN) <= MOUSE_BTN9_DBL)
return;
- // ignore mouse wheel down events since they can easily get stuck
- if (code < (MOUSE_BTN3 | MP_KEY_DOWN) || code > (MOUSE_BTN4 | MP_KEY_DOWN))
mplayer_put_key_internal(code);
if (code & MP_KEY_DOWN) {
code &= ~MP_KEY_DOWN;