annotate fifo.c @ 3509:21c7b77b3e83

fixed endian-ness for FLI and MS Video 1 decoders; fixed padding bug in FLI decoder and also implemented (untested due to lack of sample data) the FLI_COPY chunk type
author melanson
date Sun, 16 Dec 2001 00:26:21 +0000
parents 16576e05b93a
children 44198b2f42db
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
113
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
1
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
2 // keyboard:
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
3 static int keyb_fifo_put=-1;
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
4 static int keyb_fifo_get=-1;
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
5
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
6 static void make_pipe(int* pr,int* pw){
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
7 int temp[2];
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
8 if(pipe(temp)!=0) printf("Cannot make PIPE!\n");
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
9 *pr=temp[0];
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
10 *pw=temp[1];
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
11 }
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
12
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
13 static inline int my_write(int fd,unsigned char* mem,int len){
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
14 int total=0;
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
15 int len2;
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
16 while(len>0){
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
17 len2=write(fd,mem+total,len); if(len2<=0) break;
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
18 total+=len2;len-=len2;
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
19 // printf("%d bytes received, %d left\n",len2,len);
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
20 }
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
21 return total;
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
22 }
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
23
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
24 static inline int my_read(int fd,unsigned char* mem,int len){
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
25 int total=0;
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
26 int len2;
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
27 while(len>0){
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
28 len2=read(fd,mem+total,len); if(len2<=0) break;
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
29 total+=len2;len-=len2;
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
30 // printf("%d bytes received, %d left\n",len2,len);
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
31 }
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
32 return total;
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
33 }
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
34
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
35
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
36 void send_cmd(int fd,int cmd){
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
37 int fifo_cmd=cmd;
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
38 write(fd,&fifo_cmd,4);
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
39 // fflush(control_fifo);
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
40 }
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
41
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
42
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
43 void mplayer_put_key(int code){
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
44 fd_set rfds;
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
45 struct timeval tv;
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
46
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
47 /* Watch stdin (fd 0) to see when it has input. */
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
48 FD_ZERO(&rfds);
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
49 FD_SET(keyb_fifo_put, &rfds);
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
50 tv.tv_sec = 0;
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
51 tv.tv_usec = 0;
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
52
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
53 //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
54 if(select(keyb_fifo_put+1, NULL, &rfds, NULL, &tv)>0){
113
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
55 write(keyb_fifo_put,&code,4);
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
56 // printf("*** key event %d sent ***\n",code);
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
57 } else {
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
58 // printf("*** key event dropped (FIFO is full) ***\n");
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
59 }
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
60 }
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
61
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
62 int mplayer_get_key(){
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
63 fd_set rfds;
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
64 struct timeval tv;
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
65 int code=-1;
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
66
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
67 /* Watch stdin (fd 0) to see when it has input. */
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
68 FD_ZERO(&rfds);
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
69 FD_SET(keyb_fifo_get, &rfds);
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
70 tv.tv_sec = 0;
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
71 tv.tv_usec = 0;
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
72
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
73 //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
74 if(select(keyb_fifo_put+1, &rfds, NULL, NULL, &tv)>0){
113
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
75 read(keyb_fifo_get,&code,4);
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
76 // printf("*** key event %d read ***\n",code);
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
77 }
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
78 return code;
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
79 }
f6f8f53b75ad common FIFO code moved to fifo.c
arpi_esp
parents:
diff changeset
80