[MPlayer-cvslog] CVS: main cfg-mplayer.h, 1.233, 1.234 fifo.c, 1.6, 1.7 mplayer.c, 1.815, 1.816

Reimar Döffinger CVS syncmail at mplayerhq.hu
Wed Dec 1 13:22:41 CET 2004


CVS change done by Reimar Döffinger CVS

Update of /cvsroot/mplayer/main
In directory mail:/var2/tmp/cvs-serv8485

Modified Files:
	cfg-mplayer.h fifo.c mplayer.c 
Log Message:
use a configurable-size ringbuffer instead of a pipe for buffering key events.


Index: cfg-mplayer.h
===================================================================
RCS file: /cvsroot/mplayer/main/cfg-mplayer.h,v
retrieving revision 1.233
retrieving revision 1.234
diff -u -r1.233 -r1.234
--- cfg-mplayer.h	26 Nov 2004 10:06:09 -0000	1.233
+++ cfg-mplayer.h	1 Dec 2004 12:22:38 -0000	1.234
@@ -405,6 +405,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
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- fifo.c	5 Nov 2004 04:13:25 -0000	1.6
+++ fifo.c	1 Dec 2004 12:22:39 -0000	1.7
@@ -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)
+    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;
 }

Index: mplayer.c
===================================================================
RCS file: /cvsroot/mplayer/main/mplayer.c,v
retrieving revision 1.815
retrieving revision 1.816
diff -u -r1.815 -r1.816
--- mplayer.c	26 Nov 2004 10:32:53 -0000	1.815
+++ mplayer.c	1 Dec 2004 12:22:39 -0000	1.816
@@ -1312,7 +1312,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-cvslog mailing list