mirror of
https://github.com/mpv-player/mpv
synced 2025-01-02 21:12:23 +00:00
use a configurable-size ringbuffer instead of a pipe for buffering key events.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@14078 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
153d3325cd
commit
e6524e5b09
@ -566,6 +566,17 @@ several 'echo "seek 10" > mp_pipe' and the pipe will stay valid.
|
||||
.PD 1
|
||||
.
|
||||
.TP
|
||||
.B \-key-fifo-size <2\-65000>
|
||||
Specify the size of the FIFO that buffers key events (default: 10).
|
||||
A FIFO of size n can buffer (n - 1) events.
|
||||
If it is too small some events may be lost (leading to e.g. "stuck mouse
|
||||
button").
|
||||
If it is too big, MPlayer may seem to hang while it processes the buffered
|
||||
events.
|
||||
To get the same behaviour as before this option was introduced, set it to
|
||||
2 for linux or 1024 for windows.
|
||||
.
|
||||
.TP
|
||||
.B \-lircconf <filename> (LIRC only)
|
||||
Specifies a configuration file for LIRC (default: ~/\:.lircrc).
|
||||
.
|
||||
|
@ -405,6 +405,7 @@ m_option_t mplayer_opts[]={
|
||||
|
||||
{"slave", &slave_mode, CONF_TYPE_FLAG,CONF_GLOBAL , 0, 1, NULL},
|
||||
{"use-stdin", "-use-stdin has been renamed to -noconsolecontrols, use that instead.", CONF_TYPE_PRINT, 0, 0, 0, NULL},
|
||||
{"key-fifo-size", &key_fifo_size, CONF_TYPE_INT, CONF_RANGE, 2, 65000, NULL},
|
||||
{"noconsolecontrols", &noconsolecontrols, CONF_TYPE_FLAG, CONF_GLOBAL, 0, 1, NULL},
|
||||
{"consolecontrols", &noconsolecontrols, CONF_TYPE_FLAG, CONF_GLOBAL, 0, 0, NULL},
|
||||
|
||||
|
16
fifo.c
16
fifo.c
@ -1,5 +1,5 @@
|
||||
|
||||
#ifndef HAVE_NO_POSIX_SELECT
|
||||
#if 0
|
||||
|
||||
// keyboard:
|
||||
static int keyb_fifo_put=-1;
|
||||
@ -34,24 +34,28 @@ void mplayer_put_key(int code){
|
||||
|
||||
#else
|
||||
|
||||
#define KEY_FIFO_SIZE 1024
|
||||
static int key_fifo_data[KEY_FIFO_SIZE];
|
||||
int key_fifo_size = 10;
|
||||
static int *key_fifo_data = NULL;
|
||||
static int key_fifo_read=0;
|
||||
static int key_fifo_write=0;
|
||||
|
||||
void mplayer_put_key(int code){
|
||||
// printf("mplayer_put_key(%d)\n",code);
|
||||
if(((key_fifo_write+1)%KEY_FIFO_SIZE)==key_fifo_read) return; // FIFO FULL!!
|
||||
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!!
|
||||
key_fifo_data[key_fifo_write]=code;
|
||||
key_fifo_write=(key_fifo_write+1)%KEY_FIFO_SIZE;
|
||||
key_fifo_write=(key_fifo_write+1)%key_fifo_size;
|
||||
}
|
||||
|
||||
int mplayer_get_key(int fd){
|
||||
int key;
|
||||
// printf("mplayer_get_key(%d)\n",fd);
|
||||
if (key_fifo_data == NULL)
|
||||
return MP_INPUT_NOTHING;
|
||||
if(key_fifo_write==key_fifo_read) return MP_INPUT_NOTHING;
|
||||
key=key_fifo_data[key_fifo_read];
|
||||
key_fifo_read=(key_fifo_read+1)%KEY_FIFO_SIZE;
|
||||
key_fifo_read=(key_fifo_read+1)%key_fifo_size;
|
||||
// printf("mplayer_get_key => %d\n",key);
|
||||
return key;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user