comparison mplayer.c @ 9831:0397b461f0fb

MINGW32 port and select()less fifocode by Arpi
author faust3
date Fri, 04 Apr 2003 20:02:53 +0000
parents 3db72324a0fe
children 09d630a4f991
comparison
equal deleted inserted replaced
9830:e2134d2f18fb 9831:0397b461f0fb
3 #include <stdio.h> 3 #include <stdio.h>
4 #include <stdlib.h> 4 #include <stdlib.h>
5 #include <string.h> 5 #include <string.h>
6 #include <unistd.h> 6 #include <unistd.h>
7 7
8 #include <sys/ioctl.h>
9 // #include <sys/mman.h> 8 // #include <sys/mman.h>
10 #include <sys/types.h> 9 #include <sys/types.h>
10 #ifndef __MINGW32__
11 #include <sys/ioctl.h>
11 #include <sys/wait.h> 12 #include <sys/wait.h>
13 #else
14 #define SIGHUP 1 /* hangup */
15 #define SIGQUIT 3 /* quit */
16 #define SIGKILL 9 /* kill (cannot be caught or ignored) */
17 #define SIGBUS 10 /* bus error */
18 #endif
19
12 #include <sys/time.h> 20 #include <sys/time.h>
13 #include <sys/stat.h> 21 #include <sys/stat.h>
14 22
15 #include <signal.h> 23 #include <signal.h>
16 #include <time.h> 24 #include <time.h>
463 static int sig_count=0; 471 static int sig_count=0;
464 ++sig_count; 472 ++sig_count;
465 if(sig_count==5 || (inited_flags==0 && sig_count>1)) exit(1); 473 if(sig_count==5 || (inited_flags==0 && sig_count>1)) exit(1);
466 if(sig_count>5){ 474 if(sig_count>5){
467 // can't stop :( 475 // can't stop :(
476 #ifndef __MINGW32__
468 kill(getpid(),SIGKILL); 477 kill(getpid(),SIGKILL);
478 #endif
469 } 479 }
470 mp_msg(MSGT_CPLAYER,MSGL_FATAL,"\n" MSGTR_IntBySignal,x, 480 mp_msg(MSGT_CPLAYER,MSGL_FATAL,"\n" MSGTR_IntBySignal,x,
471 current_module?current_module:mp_gettext("unknown") 481 current_module?current_module:mp_gettext("unknown")
472 ); 482 );
473 if(sig_count==1) 483 if(sig_count==1)
506 if (m_config_parse_config_file(conf, CONFDIR"/mplayer.conf") < 0) 516 if (m_config_parse_config_file(conf, CONFDIR"/mplayer.conf") < 0)
507 exit(1); 517 exit(1);
508 if ((conffile = get_path("")) == NULL) { 518 if ((conffile = get_path("")) == NULL) {
509 mp_msg(MSGT_CPLAYER,MSGL_WARN,MSGTR_NoHomeDir); 519 mp_msg(MSGT_CPLAYER,MSGL_WARN,MSGTR_NoHomeDir);
510 } else { 520 } else {
521 #ifdef __MINGW32__
522 mkdir(conffile);
523 #else
511 mkdir(conffile, 0777); 524 mkdir(conffile, 0777);
525 #endif
512 free(conffile); 526 free(conffile);
513 if ((conffile = get_path("config")) == NULL) { 527 if ((conffile = get_path("config")) == NULL) {
514 mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_GetpathProblem); 528 mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_GetpathProblem);
515 } else { 529 } else {
516 if ((conffile_fd = open(conffile, O_CREAT | O_EXCL | O_WRONLY, 0666)) != -1) { 530 if ((conffile_fd = open(conffile, O_CREAT | O_EXCL | O_WRONLY, 0666)) != -1) {
1003 #ifdef USE_TERMCAP 1017 #ifdef USE_TERMCAP
1004 if ( !use_gui ) load_termcap(NULL); // load key-codes 1018 if ( !use_gui ) load_termcap(NULL); // load key-codes
1005 #endif 1019 #endif
1006 1020
1007 // ========== Init keyboard FIFO (connection to libvo) ============ 1021 // ========== Init keyboard FIFO (connection to libvo) ============
1008 make_pipe(&keyb_fifo_get,&keyb_fifo_put);
1009 1022
1010 // Init input system 1023 // Init input system
1011 current_module = "init_input"; 1024 current_module = "init_input";
1012 mp_input_init(); 1025 mp_input_init();
1026 #ifndef HAVE_NO_POSIX_SELECT
1027 make_pipe(&keyb_fifo_get,&keyb_fifo_put);
1028
1013 if(keyb_fifo_get > 0) 1029 if(keyb_fifo_get > 0)
1014 mp_input_add_key_fd(keyb_fifo_get,1,NULL,NULL); 1030 mp_input_add_key_fd(keyb_fifo_get,1,NULL,NULL);
1031 #else
1032 mp_input_add_key_fd(-1,0,mplayer_get_key,NULL);
1033 #endif
1015 if(slave_mode) 1034 if(slave_mode)
1016 mp_input_add_cmd_fd(0,1,NULL,NULL); 1035 mp_input_add_cmd_fd(0,1,NULL,NULL);
1017 else if(!use_stdin) 1036 else if(!use_stdin)
1037 #ifndef HAVE_NO_POSIX_SELECT
1018 mp_input_add_key_fd(0,1,NULL,NULL); 1038 mp_input_add_key_fd(0,1,NULL,NULL);
1039 #else
1040 mp_input_add_key_fd(0,0,NULL,NULL);
1041 #endif
1042
1019 inited_flags|=INITED_INPUT; 1043 inited_flags|=INITED_INPUT;
1020 current_module = NULL; 1044 current_module = NULL;
1021 1045
1022 #ifdef HAVE_MENU 1046 #ifdef HAVE_MENU
1023 if(use_menu) { 1047 if(use_menu) {
3236 } 3260 }
3237 current_module=NULL; 3261 current_module=NULL;
3238 } 3262 }
3239 #endif 3263 #endif
3240 3264
3265 #ifdef HAVE_X11
3241 if (stop_xscreensaver && sh_video) { 3266 if (stop_xscreensaver && sh_video) {
3242 current_module="stop_xscreensaver"; 3267 current_module="stop_xscreensaver";
3243 xscreensaver_heartbeat(sh_video->pts); 3268 xscreensaver_heartbeat(sh_video->pts);
3244 current_module=NULL; 3269 current_module=NULL;
3245 } 3270 }
3271 #endif
3246 3272
3247 // DVD sub: 3273 // DVD sub:
3248 if(vo_config_count && vo_spudec) { 3274 if(vo_config_count && vo_spudec) {
3249 unsigned char* packet=NULL; 3275 unsigned char* packet=NULL;
3250 int len,timestamp; 3276 int len,timestamp;