liba52 asm optimizations ported to amd64
[mplayer.git] / fifo.c
blob5820a30a53baf67e524cd3239bd227002e8c318c
2 #if 0
4 // keyboard:
5 static int keyb_fifo_put=-1;
6 static int keyb_fifo_get=-1;
8 static void set_nonblock_flag(int fd) {
9 int oldflags;
11 oldflags = fcntl(fd, F_GETFL, 0);
12 if (oldflags != -1) {
13 if (fcntl(keyb_fifo_put, F_SETFL, oldflags | O_NONBLOCK) != -1) {
14 return;
17 mp_msg(MSGT_INPUT,MSGL_ERR,"Cannot set nonblocking mode for fd %d!\n", fd);
20 static void make_pipe(int* pr,int* pw){
21 int temp[2];
22 if(pipe(temp)!=0) mp_msg(MSGT_FIXME, MSGL_FIXME, MSGTR_CannotMakePipe);
23 *pr=temp[0];
24 *pw=temp[1];
25 set_nonblock_flag(temp[1]);
28 void mplayer_put_key(int code){
30 if( write(keyb_fifo_put,&code,4) != 4 ){
31 mp_msg(MSGT_INPUT,MSGL_ERR,"*** key event dropped (FIFO is full) ***\n");
35 #else
37 int key_fifo_size = 10;
38 static int *key_fifo_data = NULL;
39 static int key_fifo_read=0;
40 static int key_fifo_write=0;
42 void mplayer_put_key(int code){
43 // printf("mplayer_put_key(%d)\n",code);
44 if (key_fifo_data == NULL)
45 key_fifo_data = malloc(key_fifo_size * sizeof(int));
46 if(((key_fifo_write+1)%key_fifo_size)==key_fifo_read) return; // FIFO FULL!!
47 key_fifo_data[key_fifo_write]=code;
48 key_fifo_write=(key_fifo_write+1)%key_fifo_size;
51 int mplayer_get_key(int fd){
52 int key;
53 // printf("mplayer_get_key(%d)\n",fd);
54 if (key_fifo_data == NULL)
55 return MP_INPUT_NOTHING;
56 if(key_fifo_write==key_fifo_read) return MP_INPUT_NOTHING;
57 key=key_fifo_data[key_fifo_read];
58 key_fifo_read=(key_fifo_read+1)%key_fifo_size;
59 // printf("mplayer_get_key => %d\n",key);
60 return key;
63 #endif