Mercurial > mplayer.hg
comparison mp_fifo.c @ 33017:cc8cef372901
Make "stuck keys" problem impossibly by resetting the internal
key state when our key fifo overflowed.
author | reimar |
---|---|
date | Thu, 24 Mar 2011 22:11:18 +0000 |
parents | 88a7bd86e3ac |
children | d88b8a9e989e |
comparison
equal
deleted
inserted
replaced
33016:88a7bd86e3ac | 33017:cc8cef372901 |
---|---|
33 key_fifo_data = malloc(key_fifo_size * sizeof(int)); | 33 key_fifo_data = malloc(key_fifo_size * sizeof(int)); |
34 if(!fifo_free) return; // FIFO FULL!! | 34 if(!fifo_free) return; // FIFO FULL!! |
35 // reserve some space for key release events to avoid stuck keys | 35 // reserve some space for key release events to avoid stuck keys |
36 if((code & MP_KEY_DOWN) && fifo_free < (key_fifo_size >> 1)) | 36 if((code & MP_KEY_DOWN) && fifo_free < (key_fifo_size >> 1)) |
37 return; | 37 return; |
38 // in the worst case, just reset key state | |
39 if (fifo_free == 1) | |
40 code = MP_KEY_RELEASE_ALL; | |
38 key_fifo_data[key_fifo_write % key_fifo_size]=code; | 41 key_fifo_data[key_fifo_write % key_fifo_size]=code; |
39 key_fifo_write++; | 42 key_fifo_write++; |
40 } | 43 } |
41 | 44 |
42 int mplayer_get_key(int fd){ | 45 int mplayer_get_key(int fd){ |