Mercurial > mplayer.hg
annotate fifo.c @ 12395:b969547bb0b1
bigendian fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
with #if defined(WORDS_BIGENDIAN) && (WORDS_BIGENDIAN == 1) -> #ifdef WORDS_BIGENDIAN by me
author | michael |
---|---|
date | Sun, 02 May 2004 14:26:28 +0000 |
parents | 0397b461f0fb |
children | 11b249ef87b0 |
rev | line source |
---|---|
9831 | 1 |
2 #ifndef HAVE_NO_POSIX_SELECT | |
113 | 3 |
4 // keyboard: | |
5 static int keyb_fifo_put=-1; | |
6 static int keyb_fifo_get=-1; | |
7 | |
8 static void make_pipe(int* pr,int* pw){ | |
9 int temp[2]; | |
10 if(pipe(temp)!=0) printf("Cannot make PIPE!\n"); | |
11 *pr=temp[0]; | |
12 *pw=temp[1]; | |
13 } | |
14 | |
15 void mplayer_put_key(int code){ | |
16 fd_set rfds; | |
17 struct timeval tv; | |
18 | |
19 /* Watch stdin (fd 0) to see when it has input. */ | |
20 FD_ZERO(&rfds); | |
21 FD_SET(keyb_fifo_put, &rfds); | |
22 tv.tv_sec = 0; | |
23 tv.tv_usec = 0; | |
24 | |
25 //retval = select(keyb_fifo_put+1, &rfds, NULL, NULL, &tv); | |
3014
16576e05b93a
Profiling fix by Artur Skawina <skawina@geocities.com>
atmos4
parents:
113
diff
changeset
|
26 if(select(keyb_fifo_put+1, NULL, &rfds, NULL, &tv)>0){ |
113 | 27 write(keyb_fifo_put,&code,4); |
28 // printf("*** key event %d sent ***\n",code); | |
29 } else { | |
30 // printf("*** key event dropped (FIFO is full) ***\n"); | |
31 } | |
32 } | |
9831 | 33 |
34 #else | |
35 | |
36 #define KEY_FIFO_SIZE 1024 | |
37 static int key_fifo_data[KEY_FIFO_SIZE]; | |
38 static int key_fifo_read=0; | |
39 static int key_fifo_write=0; | |
40 | |
41 void mplayer_put_key(int code){ | |
42 // printf("mplayer_put_key(%d)\n",code); | |
43 if(((key_fifo_write+1)%KEY_FIFO_SIZE)==key_fifo_read) return; // FIFO FULL!! | |
44 key_fifo_data[key_fifo_write]=code; | |
45 key_fifo_write=(key_fifo_write+1)%KEY_FIFO_SIZE; | |
46 } | |
47 | |
48 int mplayer_get_key(int fd){ | |
49 int key; | |
50 // printf("mplayer_get_key(%d)\n",fd); | |
51 if(key_fifo_write==key_fifo_read) return MP_INPUT_NOTHING; | |
52 key=key_fifo_data[key_fifo_read]; | |
53 key_fifo_read=(key_fifo_read+1)%KEY_FIFO_SIZE; | |
54 // printf("mplayer_get_key => %d\n",key); | |
55 return key; | |
56 } | |
57 | |
58 #endif | |
59 |