Mercurial > mplayer.hg
comparison input/input.c @ 22751:3d83d77f5a6b
Invert logic for HAVE_NO_POSIX_SELECT to HAVE_POSIX_SELECT to be in line
with the other HAVE_ #defines throughout the codebase.
author | diego |
---|---|
date | Wed, 21 Mar 2007 08:24:20 +0000 |
parents | e1859558b37d |
children | f6c225ffe60d |
comparison
equal
deleted
inserted
replaced
22750:8e7b3260e985 | 22751:3d83d77f5a6b |
---|---|
932 return ret; | 932 return ret; |
933 } | 933 } |
934 | 934 |
935 int | 935 int |
936 mp_input_read_key_code(int time) { | 936 mp_input_read_key_code(int time) { |
937 #ifndef HAVE_NO_POSIX_SELECT | 937 #ifdef HAVE_POSIX_SELECT |
938 fd_set fds; | 938 fd_set fds; |
939 struct timeval tv,*time_val; | 939 struct timeval tv,*time_val; |
940 #endif | 940 #endif |
941 int i,n=0,max_fd = 0, did_sleep = 0; | 941 int i,n=0,max_fd = 0, did_sleep = 0; |
942 static int last_loop = 0; | 942 static int last_loop = 0; |
946 if (time) | 946 if (time) |
947 usec_sleep(time * 1000); | 947 usec_sleep(time * 1000); |
948 return MP_INPUT_NOTHING; | 948 return MP_INPUT_NOTHING; |
949 } | 949 } |
950 | 950 |
951 #ifndef HAVE_NO_POSIX_SELECT | 951 #ifdef HAVE_POSIX_SELECT |
952 FD_ZERO(&fds); | 952 FD_ZERO(&fds); |
953 #endif | 953 #endif |
954 // Remove fd marked as dead and build the fd_set | 954 // Remove fd marked as dead and build the fd_set |
955 // n == number of fd's to be select() checked | 955 // n == number of fd's to be select() checked |
956 for(i = 0; (unsigned int)i < num_key_fd; i++) { | 956 for(i = 0; (unsigned int)i < num_key_fd; i++) { |
960 continue; | 960 continue; |
961 } else if(key_fds[i].flags & MP_FD_NO_SELECT) | 961 } else if(key_fds[i].flags & MP_FD_NO_SELECT) |
962 continue; | 962 continue; |
963 if(key_fds[i].fd > max_fd) | 963 if(key_fds[i].fd > max_fd) |
964 max_fd = key_fds[i].fd; | 964 max_fd = key_fds[i].fd; |
965 #ifndef HAVE_NO_POSIX_SELECT | 965 #ifdef HAVE_POSIX_SELECT |
966 FD_SET(key_fds[i].fd,&fds); | 966 FD_SET(key_fds[i].fd,&fds); |
967 #endif | 967 #endif |
968 n++; | 968 n++; |
969 } | 969 } |
970 | 970 |
971 #ifndef HAVE_NO_POSIX_SELECT | 971 #ifdef HAVE_POSIX_SELECT |
972 // if we have fd's without MP_FD_NO_SELECT flag, call select(): | 972 // if we have fd's without MP_FD_NO_SELECT flag, call select(): |
973 if(n>0){ | 973 if(n>0){ |
974 | 974 |
975 if(time >= 0 ) { | 975 if(time >= 0 ) { |
976 tv.tv_sec=time/1000; | 976 tv.tv_sec=time/1000; |
999 i = -1; | 999 i = -1; |
1000 last_loop++; | 1000 last_loop++; |
1001 last_loop %= (num_key_fd+1); | 1001 last_loop %= (num_key_fd+1); |
1002 continue; | 1002 continue; |
1003 } | 1003 } |
1004 #ifndef HAVE_NO_POSIX_SELECT | 1004 #ifdef HAVE_POSIX_SELECT |
1005 // No input from this fd | 1005 // No input from this fd |
1006 if(! (key_fds[i].flags & MP_FD_NO_SELECT) && ! FD_ISSET(key_fds[i].fd,&fds) && key_fds[i].fd != 0) | 1006 if(! (key_fds[i].flags & MP_FD_NO_SELECT) && ! FD_ISSET(key_fds[i].fd,&fds) && key_fds[i].fd != 0) |
1007 continue; | 1007 continue; |
1008 #endif | 1008 #endif |
1009 if(key_fds[i].fd == 0) { // stdin is handled by getch2 | 1009 if(key_fds[i].fd == 0) { // stdin is handled by getch2 |
1122 return NULL; | 1122 return NULL; |
1123 } | 1123 } |
1124 | 1124 |
1125 static mp_cmd_t* | 1125 static mp_cmd_t* |
1126 mp_input_read_cmds(int time) { | 1126 mp_input_read_cmds(int time) { |
1127 #ifndef HAVE_NO_POSIX_SELECT | 1127 #ifdef HAVE_POSIX_SELECT |
1128 fd_set fds; | 1128 fd_set fds; |
1129 struct timeval tv,*time_val; | 1129 struct timeval tv,*time_val; |
1130 #endif | 1130 #endif |
1131 int i,n = 0,max_fd = 0,got_cmd = 0; | 1131 int i,n = 0,max_fd = 0,got_cmd = 0; |
1132 mp_cmd_t* ret; | 1132 mp_cmd_t* ret; |
1133 static int last_loop = 0; | 1133 static int last_loop = 0; |
1134 | 1134 |
1135 if(num_cmd_fd == 0) | 1135 if(num_cmd_fd == 0) |
1136 return NULL; | 1136 return NULL; |
1137 | 1137 |
1138 #ifndef HAVE_NO_POSIX_SELECT | 1138 #ifdef HAVE_POSIX_SELECT |
1139 FD_ZERO(&fds); | 1139 FD_ZERO(&fds); |
1140 #endif | 1140 #endif |
1141 for(i = 0; (unsigned int)i < num_cmd_fd ; i++) { | 1141 for(i = 0; (unsigned int)i < num_cmd_fd ; i++) { |
1142 if( (cmd_fds[i].flags & MP_FD_DEAD) || (cmd_fds[i].flags & MP_FD_EOF) ) { | 1142 if( (cmd_fds[i].flags & MP_FD_DEAD) || (cmd_fds[i].flags & MP_FD_EOF) ) { |
1143 mp_input_rm_cmd_fd(cmd_fds[i].fd); | 1143 mp_input_rm_cmd_fd(cmd_fds[i].fd); |
1147 continue; | 1147 continue; |
1148 if(cmd_fds[i].flags & MP_FD_GOT_CMD) | 1148 if(cmd_fds[i].flags & MP_FD_GOT_CMD) |
1149 got_cmd = 1; | 1149 got_cmd = 1; |
1150 if(cmd_fds[i].fd > max_fd) | 1150 if(cmd_fds[i].fd > max_fd) |
1151 max_fd = cmd_fds[i].fd; | 1151 max_fd = cmd_fds[i].fd; |
1152 #ifndef HAVE_NO_POSIX_SELECT | 1152 #ifdef HAVE_POSIX_SELECT |
1153 FD_SET(cmd_fds[i].fd,&fds); | 1153 FD_SET(cmd_fds[i].fd,&fds); |
1154 #endif | 1154 #endif |
1155 n++; | 1155 n++; |
1156 } | 1156 } |
1157 | 1157 |
1158 if(num_cmd_fd == 0) | 1158 if(num_cmd_fd == 0) |
1159 return NULL; | 1159 return NULL; |
1160 | 1160 |
1161 #ifndef HAVE_NO_POSIX_SELECT | 1161 #ifdef HAVE_POSIX_SELECT |
1162 if(time >= 0) { | 1162 if(time >= 0) { |
1163 tv.tv_sec=time/1000; | 1163 tv.tv_sec=time/1000; |
1164 tv.tv_usec = (time%1000)*1000; | 1164 tv.tv_usec = (time%1000)*1000; |
1165 time_val = &tv; | 1165 time_val = &tv; |
1166 } else | 1166 } else |
1187 i = -1; | 1187 i = -1; |
1188 last_loop++; | 1188 last_loop++; |
1189 last_loop %= (num_cmd_fd+1); | 1189 last_loop %= (num_cmd_fd+1); |
1190 continue; | 1190 continue; |
1191 } | 1191 } |
1192 #ifndef HAVE_NO_POSIX_SELECT | 1192 #ifdef HAVE_POSIX_SELECT |
1193 if( ! (cmd_fds[i].flags & MP_FD_NO_SELECT) && ! FD_ISSET(cmd_fds[i].fd,&fds) && ! (cmd_fds[i].flags & MP_FD_GOT_CMD) ) | 1193 if( ! (cmd_fds[i].flags & MP_FD_NO_SELECT) && ! FD_ISSET(cmd_fds[i].fd,&fds) && ! (cmd_fds[i].flags & MP_FD_GOT_CMD) ) |
1194 continue; | 1194 continue; |
1195 #endif | 1195 #endif |
1196 | 1196 |
1197 r = mp_input_read_cmd(&cmd_fds[i],&cmd); | 1197 r = mp_input_read_cmd(&cmd_fds[i],&cmd); |