summaryrefslogtreecommitdiffstats
path: root/fifo.c
diff options
context:
space:
mode:
authorreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>2004-12-01 12:22:39 +0000
committerreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>2004-12-01 12:22:39 +0000
commite6524e5b0958e8b798e160c6ae555f5495c5f5eb (patch)
tree9747e1f764d98601bb8f1c2bdf404e53762f63b3 /fifo.c
parent153d3325cd34ae1d4c73ab73e63b4cd9aaace069 (diff)
downloadmpv-e6524e5b0958e8b798e160c6ae555f5495c5f5eb.tar.bz2
mpv-e6524e5b0958e8b798e160c6ae555f5495c5f5eb.tar.xz
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
Diffstat (limited to 'fifo.c')
-rw-r--r--fifo.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/fifo.c b/fifo.c
index ea76e9c906..5820a30a53 100644
--- a/fifo.c
+++ b/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;
}