[MPlayer-dev-eng] [PATCH] Use ringbuffer code instead of pipe for keyboard buffering
Reimar Döffinger
Reimar.Doeffinger at stud.uni-karlsruhe.de
Tue Nov 23 21:49:11 CET 2004
Hi,
this patch makes MPlayer always use the ringbuffer code it now already uses for
e.g. Windows.
It also add a commandline option that allows to specify how big that
buffer should be (because MPlayer can take quite some time to process
them, that's also why the default is 10).
The manpage part is still missing (in case somebody wants to write one:
in a ringbuffer of size n fit n-1 key events).
Greetings,
Reimar Döffinger
-------------- next part --------------
Index: cfg-mplayer.h
===================================================================
RCS file: /cvsroot/mplayer/main/cfg-mplayer.h,v
retrieving revision 1.231
diff -u -r1.231 cfg-mplayer.h
--- cfg-mplayer.h 14 Nov 2004 11:27:57 -0000 1.231
+++ cfg-mplayer.h 23 Nov 2004 20:41:21 -0000
@@ -413,6 +413,7 @@
{"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},
Index: fifo.c
===================================================================
RCS file: /cvsroot/mplayer/main/fifo.c,v
retrieving revision 1.6
diff -u -r1.6 fifo.c
--- fifo.c 5 Nov 2004 04:13:25 -0000 1.6
+++ fifo.c 23 Nov 2004 20:41:21 -0000
@@ -1,5 +1,5 @@
-#ifndef HAVE_NO_POSIX_SELECT
+#if 0
// keyboard:
static int keyb_fifo_put=-1;
@@ -34,24 +34,28 @@
#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)
+ key_fifo_data = malloc(key_fifo_size * sizeof(int));
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;
}
Index: mplayer.c
===================================================================
RCS file: /cvsroot/mplayer/main/mplayer.c,v
retrieving revision 1.813
diff -u -r1.813 mplayer.c
--- mplayer.c 20 Nov 2004 10:51:13 -0000 1.813
+++ mplayer.c 23 Nov 2004 20:41:32 -0000
@@ -1307,7 +1307,7 @@
// Init input system
current_module = "init_input";
mp_input_init();
-#ifndef HAVE_NO_POSIX_SELECT
+#if 0
make_pipe(&keyb_fifo_get,&keyb_fifo_put);
if(keyb_fifo_get > 0)
More information about the MPlayer-dev-eng
mailing list