comparison mplayer.c @ 723:c3e0bdb64027

add gui support
author pontscho
date Tue, 08 May 2001 12:17:03 +0000
parents b570318ac2f4
children cd1f0d4de0b8
comparison
equal deleted inserted replaced
722:b570318ac2f4 723:c3e0bdb64027
86 #endif 86 #endif
87 87
88 #include "help_mp.h" 88 #include "help_mp.h"
89 89
90 #define DEBUG if(0) 90 #define DEBUG if(0)
91 #ifdef HAVE_GUI
92 int nogui=1; // new
93 #endif
91 int verbose=0; 94 int verbose=0;
92 95
93 #define ABS(x) (((x)>=0)?(x):(-(x))) 96 #define ABS(x) (((x)>=0)?(x):(-(x)))
94 97
95 static subtitle* subtitles=NULL; 98 static subtitle* subtitles=NULL;
323 326
324 static int play_in_bg=0; 327 static int play_in_bg=0;
325 328
326 extern void avi_fixate(); 329 extern void avi_fixate();
327 330
331 #ifdef HAVE_GUI
332 #include "../Gui/mplayer/psignal.h"
333 #endif
334
328 void exit_player(char* how){ 335 void exit_player(char* how){
336
337 #ifdef HAVE_GUI
338 if ( !nogui )
339 {
340 if ( how != NULL )
341 {
342 if ( !strcmp( how,"Quit" ) ) mplSendMessage( mplEndOfFile );
343 if ( !strcmp( how,"End of file" ) ) mplSendMessage( mplEndOfFile );
344 if ( !strcmp( how,"audio_init" ) ) mplSendMessage( mplAudioError );
345 }
346 else mplSendMessage( mplUnknowError );
347 }
348 #endif
349
329 if(how) printf("\nExiting... (%s)\n",how); 350 if(how) printf("\nExiting... (%s)\n",how);
330 if(verbose) printf("max framesize was %d bytes\n",max_framesize); 351 if(verbose) printf("max framesize was %d bytes\n",max_framesize);
331 // restore terminal: 352 // restore terminal:
332 getch2_disable(); 353 getch2_disable();
333 video_out->uninit(); 354 video_out->uninit();
338 xmm_Exit( &xmm ); 359 xmm_Exit( &xmm );
339 } 360 }
340 #endif 361 #endif
341 if(encode_name) avi_fixate(); 362 if(encode_name) avi_fixate();
342 #ifdef HAVE_LIRC 363 #ifdef HAVE_LIRC
364 #ifdef HAVE_GUI
365 if ( nogui )
366 #endif
343 lirc_mp_cleanup(); 367 lirc_mp_cleanup();
344 #endif 368 #endif
345 //if(play_in_bg) system("xsetroot -solid \\#000000"); 369 //if(play_in_bg) system("xsetroot -solid \\#000000");
346 exit(1); 370 exit(1);
347 } 371 }
357 kill(getpid(),SIGKILL); 381 kill(getpid(),SIGKILL);
358 } 382 }
359 printf("\nMPlayer interrupted by signal %d in module: %s \n",x, 383 printf("\nMPlayer interrupted by signal %d in module: %s \n",x,
360 current_module?current_module:"unknown" 384 current_module?current_module:"unknown"
361 ); 385 );
386 #ifdef HAVE_GUI
387 if ( !nogui )
388 {
389 mplShMem->items.error.signal=x;
390 strcpy( mplShMem->items.error.module,current_module?current_module:"unknown" );
391 }
392 #endif
362 exit_player(NULL); 393 exit_player(NULL);
363 } 394 }
364 395
365 int divx_quality=0; 396 int divx_quality=0;
366 397
370 extern void mpeg2_allocate_image_buffers(picture_t * picture); 401 extern void mpeg2_allocate_image_buffers(picture_t * picture);
371 extern void write_avi_header_1(FILE *f,int fcc,float fps,int width,int height); 402 extern void write_avi_header_1(FILE *f,int fcc,float fps,int width,int height);
372 extern int vo_init(void); 403 extern int vo_init(void);
373 extern int decode_audio(sh_audio_t *sh_audio,unsigned char *buf,int maxlen); 404 extern int decode_audio(sh_audio_t *sh_audio,unsigned char *buf,int maxlen);
374 405
375 int main(int argc,char* argv[], char *envp[]){
376 char* filename=NULL; //"MI2-Trailer.avi"; 406 char* filename=NULL; //"MI2-Trailer.avi";
377 int i; 407 int i;
378 int seek_to_sec=0; 408 int seek_to_sec=0;
379 int seek_to_byte=0; 409 int seek_to_byte=0;
380 int f; // filedes 410 int f; // filedes
435 int sub_auto = 1; 465 int sub_auto = 1;
436 char *stream_dump_name=NULL; 466 char *stream_dump_name=NULL;
437 int stream_dump_type=0; 467 int stream_dump_type=0;
438 //int user_bpp=0; 468 //int user_bpp=0;
439 469
470 int osd_visible=100;
471 int osd_function=OSD_PLAY;
472 int osd_last_pts=-303;
473
474 int rel_seek_secs=0;
475
440 #include "mixer.h" 476 #include "mixer.h"
441 #include "cfg-mplayer.h" 477 #include "cfg-mplayer.h"
442 478
443 printf("%s",banner_text); 479 void parse_cfgfiles( void )
444 480 {
445 if (parse_config_file(conf, "/etc/mplayer.conf") < 0) 481 if (parse_config_file(conf, "/etc/mplayer.conf") < 0)
446 exit(1); 482 exit(1);
447 if ((conffile = get_path("")) == NULL) { 483 if ((conffile = get_path("")) == NULL) {
448 printf("Can't find HOME dir\n"); 484 printf("Can't find HOME dir\n");
449 } else { 485 } else {
460 if (parse_config_file(conf, conffile) < 0) 496 if (parse_config_file(conf, conffile) < 0)
461 exit(1); 497 exit(1);
462 free(conffile); 498 free(conffile);
463 } 499 }
464 } 500 }
465 if (parse_command_line(conf, argc, argv, envp, &filename) < 0) 501 }
466 exit(1); 502
467 503 #ifndef HAVE_GUI
468 // Many users forget to include command line in bugreports... 504 int main(int argc,char* argv[], char *envp[]){
469 if(verbose){ 505 #else
470 printf("CommandLine:"); 506 int mplayer(int argc,char* argv[], char *envp[]){
471 for(i=1;i<argc;i++)printf(" '%s'",argv[i]); 507 #endif
472 printf("\n"); 508
473 } 509 printf("%s",banner_text);
474 510
475 if(video_driver && strcmp(video_driver,"help")==0){ 511 #ifdef HAVE_GUI
476 printf("Available video output drivers:\n"); 512 if ( nogui )
477 i=0; 513 {
478 while (video_out_drivers[i]) { 514 #endif
479 const vo_info_t *info = video_out_drivers[i++]->get_info (); 515 if (parse_command_line(conf, argc, argv, envp, &filename) < 0) exit(1);
480 printf("\t%s\t%s\n", info->short_name, info->name); 516
481 } 517 // Many users forget to include command line in bugreports...
482 printf("\n"); 518 if(verbose){
483 exit(0); 519 printf("CommandLine:");
484 } 520 for(i=1;i<argc;i++)printf(" '%s'",argv[i]);
521 printf("\n");
522 }
523
524 if(video_driver && strcmp(video_driver,"help")==0){
525 printf("Available video output drivers:\n");
526 i=0;
527 while (video_out_drivers[i]) {
528 const vo_info_t *info = video_out_drivers[i++]->get_info ();
529 printf("\t%s\t%s\n", info->short_name, info->name);
530 }
531 printf("\n");
532 exit(0);
533 }
534 #ifdef HAVE_GUI
535 }
536 #endif
485 537
486 if(!filename){ 538 if(!filename){
487 if(vcd_track) filename="/dev/cdrom"; 539 if(vcd_track) filename="/dev/cdrom";
488 else { 540 else {
489 printf("%s",help_text); exit(0); 541 printf("%s",help_text); exit(0);
506 } 558 }
507 559
508 // check codec.conf 560 // check codec.conf
509 if(!parse_codec_cfg(get_path("codecs.conf"))){ 561 if(!parse_codec_cfg(get_path("codecs.conf"))){
510 printf("(copy/link DOCS/codecs.conf to ~/.mplayer/codecs.conf)\n"); 562 printf("(copy/link DOCS/codecs.conf to ~/.mplayer/codecs.conf)\n");
563 #ifdef HAVE_GUI
564 if ( !nogui ) { mplSendMessage( mplCodecConfNotFound ); usleep( 10000 ); }
565 #endif
511 exit(1); 566 exit(1);
512 } 567 }
513 568
514 // check font 569 // check font
515 if(font_name){ 570 if(font_name){
571 626
572 #ifdef HAVE_LIBCSS 627 #ifdef HAVE_LIBCSS
573 if (dvdimportkey) { 628 if (dvdimportkey) {
574 if (dvd_import_key(dvdimportkey)) { 629 if (dvd_import_key(dvdimportkey)) {
575 fprintf(stderr,"Error processing DVD KEY.\n"); 630 fprintf(stderr,"Error processing DVD KEY.\n");
631 #ifdef HAVE_GUI
632 if ( !nogui ) { mplSendMessage( mplErrorDVDKeyProcess ); usleep( 10000 ); }
633 #endif
576 exit(1); 634 exit(1);
577 } 635 }
578 printf("DVD command line requested key is stored for descrambling.\n"); 636 printf("DVD command line requested key is stored for descrambling.\n");
579 } 637 }
580 if (dvd_device) { 638 if (dvd_device) {
581 if (dvd_auth(dvd_device,f)) exit(0); 639 if (dvd_auth(dvd_device,f)) {
640 #ifdef HAVE_GUI
641 if ( !nogui ) { mplSendMessage( mplErrorDVDAuth ); usleep( 10000 ); }
642 #endif
643 exit(0);
644 }
582 printf("DVD auth sequence seems to be OK.\n"); 645 printf("DVD auth sequence seems to be OK.\n");
583 } 646 }
584 #endif 647 #endif
585 648
586 //============ Open & Sync stream and detect file format =============== 649 //============ Open & Sync stream and detect file format ===============
651 } 714 }
652 //=============== Unknown, exiting... =========================== 715 //=============== Unknown, exiting... ===========================
653 if(file_format==DEMUXER_TYPE_UNKNOWN){ 716 if(file_format==DEMUXER_TYPE_UNKNOWN){
654 printf("============= Sorry, this file format not recognized/supported ===============\n"); 717 printf("============= Sorry, this file format not recognized/supported ===============\n");
655 printf("=== If this file is an AVI, ASF or MPEG stream, please contact the author! ===\n"); 718 printf("=== If this file is an AVI, ASF or MPEG stream, please contact the author! ===\n");
719 #ifdef HAVE_GUI
720 if ( !nogui ) { mplSendMessage( mplUnknowFileType ); usleep( 10000 ); }
721 #endif
656 exit(1); 722 exit(1);
657 } 723 }
658 //====== File format recognized, set up these for compatibility: ========= 724 //====== File format recognized, set up these for compatibility: =========
659 d_audio=demuxer->audio; 725 d_audio=demuxer->audio;
660 d_video=demuxer->video; 726 d_video=demuxer->video;
701 if(a_pos!=-1) break; 767 if(a_pos!=-1) break;
702 } 768 }
703 } 769 }
704 if(v_pos==-1){ 770 if(v_pos==-1){
705 printf("AVI_NI: missing video stream!? contact the author, it may be a bug :(\n"); 771 printf("AVI_NI: missing video stream!? contact the author, it may be a bug :(\n");
772 #ifdef HAVE_GUI
773 if ( !nogui ) { mplSendMessage( mplErrorAVINI ); usleep( 10000 ); }
774 #endif
706 exit(1); 775 exit(1);
707 } 776 }
708 if(a_pos==-1){ 777 if(a_pos==-1){
709 printf("AVI_NI: No audio stream found -> nosound\n"); 778 printf("AVI_NI: No audio stream found -> nosound\n");
710 has_audio=0; 779 has_audio=0;
725 pts_from_bps=1; // force BPS sync! 794 pts_from_bps=1; // force BPS sync!
726 } 795 }
727 } 796 }
728 if(!ds_fill_buffer(d_video)){ 797 if(!ds_fill_buffer(d_video)){
729 printf("AVI: missing video stream!? contact the author, it may be a bug :(\n"); 798 printf("AVI: missing video stream!? contact the author, it may be a bug :(\n");
799 #ifdef HAVE_GUI
800 if ( !nogui ) { mplSendMessage( mplAVIErrorMissingVideoStream ); usleep( 10000 ); }
801 #endif
730 exit(1); 802 exit(1);
731 } 803 }
732 sh_video=d_video->sh;sh_video->ds=d_video; 804 sh_video=d_video->sh;sh_video->ds=d_video;
733 if(has_audio){ 805 if(has_audio){
734 if(verbose) printf("AVI: Searching for audio stream (id:%d)\n",d_audio->id); 806 if(verbose) printf("AVI: Searching for audio stream (id:%d)\n",d_audio->id);
766 stream_seek(demuxer->stream,demuxer->movi_start); 838 stream_seek(demuxer->stream,demuxer->movi_start);
767 demuxer->idx_pos=0; 839 demuxer->idx_pos=0;
768 // demuxer->endpos=avi_header.movi_end; 840 // demuxer->endpos=avi_header.movi_end;
769 if(!ds_fill_buffer(d_video)){ 841 if(!ds_fill_buffer(d_video)){
770 printf("ASF: missing video stream!? contact the author, it may be a bug :(\n"); 842 printf("ASF: missing video stream!? contact the author, it may be a bug :(\n");
843 #ifdef HAVE_GUI
844 if ( !nogui ) { mplSendMessage( mplASFErrorMissingVideoStream ); usleep( 10000 ); }
845 #endif
771 exit(1); 846 exit(1);
772 } 847 }
773 sh_video=d_video->sh;sh_video->ds=d_video; 848 sh_video=d_video->sh;sh_video->ds=d_video;
774 if(has_audio){ 849 if(has_audio){
775 if(verbose) printf("ASF: Searching for audio stream (id:%d)\n",d_audio->id); 850 if(verbose) printf("ASF: Searching for audio stream (id:%d)\n",d_audio->id);
834 int i=sync_video_packet(d_video); 909 int i=sync_video_packet(d_video);
835 if(i==0x1B3) break; // found it! 910 if(i==0x1B3) break; // found it!
836 if(!i || !skip_video_packet(d_video)){ 911 if(!i || !skip_video_packet(d_video)){
837 if(verbose) printf("NONE :(\n"); 912 if(verbose) printf("NONE :(\n");
838 printf("MPEG: FATAL: EOF while searching for sequence header\n"); 913 printf("MPEG: FATAL: EOF while searching for sequence header\n");
914 #ifdef HAVE_GUI
915 if ( !nogui ) { mplSendMessage( mplMPEGErrorSeqHeaderSearch ); usleep( 10000 ); }
916 #endif
839 exit(1); 917 exit(1);
840 } 918 }
841 } 919 }
842 if(verbose) printf("OK!\n"); 920 if(verbose) printf("OK!\n");
843 sh_video=d_video->sh;sh_video->ds=d_video; 921 sh_video=d_video->sh;sh_video->ds=d_video;
844 sh_video->format=1; // mpeg video 922 sh_video->format=1; // mpeg video
845 mpeg2_init(); 923 mpeg2_init();
846 // ========= Read & process sequence header & extension ============ 924 // ========= Read & process sequence header & extension ============
847 videobuffer=shmem_alloc(VIDEOBUFFER_SIZE); 925 videobuffer=shmem_alloc(VIDEOBUFFER_SIZE);
848 if(!videobuffer){ printf("Cannot allocate shared memory\n");exit(0);} 926 if(!videobuffer){
927 printf("Cannot allocate shared memory\n");
928 #ifdef HAVE_GUI
929 if ( !nogui ) { mplSendMessage( mplErrorShMemAlloc ); usleep( 10000 ); }
930 #endif
931 exit(0);
932 }
849 videobuf_len=0; 933 videobuf_len=0;
850 if(!read_video_packet(d_video)){ printf("FATAL: Cannot read sequence header!\n");exit(1);} 934 if(!read_video_packet(d_video)){
935 printf("FATAL: Cannot read sequence header!\n");
936 #ifdef HAVE_GUI
937 if ( !nogui ) { mplSendMessage( mplMPEGErrorCannotReadSeqHeader ); usleep( 10000 ); }
938 #endif
939 exit(1);
940 }
851 if(header_process_sequence_header (picture, &videobuffer[4])) { 941 if(header_process_sequence_header (picture, &videobuffer[4])) {
852 printf ("bad sequence header!\n"); exit(1); 942 printf ("bad sequence header!\n");
943 #ifdef HAVE_GUI
944 if ( !nogui ) { mplSendMessage( mplMPEGErrorBadSeqHeader ); usleep( 10000 ); }
945 #endif
946 exit(1);
853 } 947 }
854 if(sync_video_packet(d_video)==0x1B5){ // next packet is seq. ext. 948 if(sync_video_packet(d_video)==0x1B5){ // next packet is seq. ext.
855 videobuf_len=0; 949 videobuf_len=0;
856 if(!read_video_packet(d_video)){ printf("FATAL: Cannot read sequence header extension!\n");exit(1);} 950 if(!read_video_packet(d_video)){
951 printf("FATAL: Cannot read sequence header extension!\n");
952 #ifdef HAVE_GUI
953 if ( !nogui ) { mplSendMessage( mplMPEGErrorCannotReadSeqHeaderExt ); usleep( 10000 ); }
954 #endif
955 exit(1);
956 }
857 if(header_process_extension (picture, &videobuffer[4])) { 957 if(header_process_extension (picture, &videobuffer[4])) {
858 printf ("bad sequence header extension!\n"); exit(1); 958 printf ("bad sequence header extension!\n");
959 #ifdef HAVE_GUI
960 if ( !nogui ) { mplSendMessage( mplMPEGErrorBadSeqHeaderExt ); usleep( 10000 ); }
961 #endif
962 exit(1);
859 } 963 }
860 } 964 }
861 // display info: 965 // display info:
862 sh_video->fps=frameratecode2framerate[picture->frame_rate_code]*0.0001f; 966 sh_video->fps=frameratecode2framerate[picture->frame_rate_code]*0.0001f;
863 sh_video->frametime=10000.0f/(float)frameratecode2framerate[picture->frame_rate_code]; 967 sh_video->frametime=10000.0f/(float)frameratecode2framerate[picture->frame_rate_code];
938 while(1){ 1042 while(1){
939 sh_video->codec=find_codec(sh_video->format, 1043 sh_video->codec=find_codec(sh_video->format,
940 sh_video->bih?((unsigned int*) &sh_video->bih->biCompression):NULL,sh_video->codec,0); 1044 sh_video->bih?((unsigned int*) &sh_video->bih->biCompression):NULL,sh_video->codec,0);
941 if(!sh_video->codec){ 1045 if(!sh_video->codec){
942 printf("Can't find codec for video format 0x%X !\n",sh_video->format); 1046 printf("Can't find codec for video format 0x%X !\n",sh_video->format);
1047 #ifdef HAVE_GUI
1048 if ( !nogui )
1049 {
1050 mplShMem->items.videodata.format=sh_video->format;
1051 mplSendMessage( mplCantFindCodecForVideoFormat );
1052 usleep( 10000 );
1053 }
1054 #endif
943 exit(1); 1055 exit(1);
944 } 1056 }
945 if(!allow_dshow && sh_video->codec->driver==4) continue; // skip DShow 1057 if(!allow_dshow && sh_video->codec->driver==4) continue; // skip DShow
946 break; 1058 break;
947 } 1059 }
957 if(verbose) printf("vo_debug: query(0x%X) returned 0x%X\n",out_fmt,ret); 1069 if(verbose) printf("vo_debug: query(0x%X) returned 0x%X\n",out_fmt,ret);
958 if(ret) break; 1070 if(ret) break;
959 } 1071 }
960 if(i>=CODECS_MAX_OUTFMT){ 1072 if(i>=CODECS_MAX_OUTFMT){
961 printf("Sorry, selected video_out device is incompatible with this codec.\n"); 1073 printf("Sorry, selected video_out device is incompatible with this codec.\n");
1074 #ifdef HAVE_GUI
1075 if ( !nogui ) { mplSendMessage( mplIncompatibleVideoOutDevice ); usleep( 10000 ); }
1076 #endif
962 exit(1); 1077 exit(1);
963 } 1078 }
964 sh_video->outfmtidx=i; 1079 sh_video->outfmtidx=i;
965 1080
966 if(verbose) printf("vo_debug1: out_fmt=0x%08X\n",out_fmt); 1081 if(verbose) printf("vo_debug1: out_fmt=0x%08X\n",out_fmt);
967 1082
968 switch(sh_video->codec->driver){ 1083 switch(sh_video->codec->driver){
969 case 2: { 1084 case 2: {
970 if(!init_video_codec(sh_video)) exit(1); 1085 if(!init_video_codec(sh_video)) {
1086 #ifdef HAVE_GUI
1087 if ( !nogui ) { mplSendMessage( mplUnknowError ); usleep( 10000 ); }
1088 #endif
1089 exit(1);
1090 }
971 if(verbose) printf("INFO: Win32 video codec init OK!\n"); 1091 if(verbose) printf("INFO: Win32 video codec init OK!\n");
972 break; 1092 break;
973 } 1093 }
974 case 4: { // Win32/DirectShow 1094 case 4: { // Win32/DirectShow
975 #ifndef USE_DIRECTSHOW 1095 #ifndef USE_DIRECTSHOW
976 printf("MPlayer was compiled WITHOUT directshow support!\n"); 1096 printf("MPlayer was compiled WITHOUT directshow support!\n");
1097 #ifdef HAVE_GUI
1098 if ( !nogui ) { mplSendMessage( mplCompileWithoutDSSupport ); usleep( 10000 ); }
1099 #endif
977 exit(1); 1100 exit(1);
978 #else 1101 #else
979 sh_video->our_out_buffer=NULL; 1102 sh_video->our_out_buffer=NULL;
980 if(DS_VideoDecoder_Open(sh_video->codec->dll,&sh_video->codec->guid, sh_video->bih, 0, &sh_video->our_out_buffer)){ 1103 if(DS_VideoDecoder_Open(sh_video->codec->dll,&sh_video->codec->guid, sh_video->bih, 0, &sh_video->our_out_buffer)){
981 // if(DS_VideoDecoder_Open(sh_video->codec->dll,&sh_video->codec->guid, sh_video->bih, 0, NULL)){ 1104 // if(DS_VideoDecoder_Open(sh_video->codec->dll,&sh_video->codec->guid, sh_video->bih, 0, NULL)){
982 printf("ERROR: Couldn't open required DirectShow codec: %s\n",sh_video->codec->dll); 1105 printf("ERROR: Couldn't open required DirectShow codec: %s\n",sh_video->codec->dll);
983 printf("Maybe you forget to upgrade your win32 codecs?? It's time to download the new\n"); 1106 printf("Maybe you forget to upgrade your win32 codecs?? It's time to download the new\n");
984 printf("package from: ftp://thot.banki.hu/esp-team/linux/MPlayer/w32codec.zip !\n"); 1107 printf("package from: ftp://thot.banki.hu/esp-team/linux/MPlayer/w32codec.zip !\n");
985 printf("Or you should disable DShow support: make distclean;make -f Makefile.No-DS\n"); 1108 printf("Or you should disable DShow support: make distclean;make -f Makefile.No-DS\n");
1109 #ifdef HAVE_GUI
1110 if ( !nogui )
1111 {
1112 strcpy( mplShMem->items.videodata.codecdll,sh_video->codec->dll );
1113 mplSendMessage( mplDSCodecNotFound );
1114 usleep( 10000 );
1115 }
1116 #endif
986 exit(1); 1117 exit(1);
987 } 1118 }
988 1119
989 switch(out_fmt){ 1120 switch(out_fmt){
990 case IMGFMT_YUY2: 1121 case IMGFMT_YUY2:
1123 fullscreen|(vidmode<<1)|(softzoom<<2), 1254 fullscreen|(vidmode<<1)|(softzoom<<2),
1124 title,out_fmt); 1255 title,out_fmt);
1125 1256
1126 if(verbose) printf("vo_debug3: out_fmt=0x%08X\n",out_fmt); 1257 if(verbose) printf("vo_debug3: out_fmt=0x%08X\n",out_fmt);
1127 1258
1259 #ifdef HAVE_GUI
1260 if ( !nogui )
1261 {
1262 mplShMem->items.videodata.width=sh_video->disp_w;
1263 mplShMem->items.videodata.height=sh_video->disp_h;
1264 mplSendMessage( mplSetVideoData );
1265 }
1266 #endif
1267
1128 if(video_out->init(sh_video->disp_w,sh_video->disp_h, 1268 if(video_out->init(sh_video->disp_w,sh_video->disp_h,
1129 screen_size_x,screen_size_y, 1269 screen_size_x,screen_size_y,
1130 fullscreen|(vidmode<<1)|(softzoom<<2), 1270 fullscreen|(vidmode<<1)|(softzoom<<2),
1131 title,out_fmt)){ 1271 title,out_fmt)){
1132 printf("FATAL: Cannot initialize video driver!\n");exit(1); 1272 printf("FATAL: Cannot initialize video driver!\n");
1273 #ifdef HAVE_GUI
1274 if ( !nogui ) { mplSendMessage( mplCantInitVideoDriver ); usleep( 10000 ); }
1275 #endif
1276 exit(1);
1133 } 1277 }
1134 if(verbose) printf("INFO: Video OUT driver init OK!\n"); 1278 if(verbose) printf("INFO: Video OUT driver init OK!\n");
1135 1279
1136 fflush(stdout); 1280 fflush(stdout);
1137 1281
1154 double video_time_usage=0; 1298 double video_time_usage=0;
1155 double vout_time_usage=0; 1299 double vout_time_usage=0;
1156 double audio_time_usage=0; 1300 double audio_time_usage=0;
1157 int grab_frames=0; 1301 int grab_frames=0;
1158 char osd_text_buffer[64]; 1302 char osd_text_buffer[64];
1159 int osd_visible=100;
1160 int osd_function=OSD_PLAY;
1161 int osd_last_pts=-303;
1162 int drop_frame=0; 1303 int drop_frame=0;
1163 int drop_frame_cnt=0; 1304 int drop_frame_cnt=0;
1164 1305
1165 #ifdef HAVE_LIRC 1306 #ifdef HAVE_LIRC
1307 #ifdef HAVE_GUI
1308 if ( nogui )
1309 #endif
1166 lirc_mp_setup(); 1310 lirc_mp_setup();
1167 #endif 1311 #endif
1168 1312
1169 #ifdef USE_TERMCAP 1313 #ifdef USE_TERMCAP
1170 load_termcap(NULL); // load key-codes 1314 load_termcap(NULL); // load key-codes
1173 1317
1174 //========= Catch terminate signals: ================ 1318 //========= Catch terminate signals: ================
1175 // terminate requests: 1319 // terminate requests:
1176 signal(SIGTERM,exit_sighandler); // kill 1320 signal(SIGTERM,exit_sighandler); // kill
1177 signal(SIGHUP,exit_sighandler); // kill -HUP / xterm closed 1321 signal(SIGHUP,exit_sighandler); // kill -HUP / xterm closed
1178 signal(SIGINT,exit_sighandler); // Interrupt from keyboard 1322
1323 #ifdef HAVE_GUI
1324 if ( nogui )
1325 #endif
1326 signal(SIGINT,exit_sighandler); // Interrupt from keyboard
1327
1179 signal(SIGQUIT,exit_sighandler); // Quit from keyboard 1328 signal(SIGQUIT,exit_sighandler); // Quit from keyboard
1180 // fatal errors: 1329 // fatal errors:
1181 signal(SIGBUS,exit_sighandler); // bus error 1330 signal(SIGBUS,exit_sighandler); // bus error
1182 signal(SIGSEGV,exit_sighandler); // segfault 1331 signal(SIGSEGV,exit_sighandler); // segfault
1183 signal(SIGILL,exit_sighandler); // illegal instruction 1332 signal(SIGILL,exit_sighandler); // illegal instruction
1656 if(!osd_visible) vo_osd_progbar_type=-1; // disable 1805 if(!osd_visible) vo_osd_progbar_type=-1; // disable
1657 } 1806 }
1658 1807
1659 if(osd_function==OSD_PAUSE){ 1808 if(osd_function==OSD_PAUSE){
1660 printf("\n------ PAUSED -------\r");fflush(stdout); 1809 printf("\n------ PAUSED -------\r");fflush(stdout);
1661 while( 1810 #ifdef HAVE_GUI
1811 if ( nogui )
1812 {
1813 #endif
1814 while(
1662 #ifdef HAVE_LIRC 1815 #ifdef HAVE_LIRC
1663 lirc_mp_getinput()<=0 && 1816 lirc_mp_getinput()<=0 &&
1664 #endif 1817 #endif
1665 (!f || getch2(20)<=0) && mplayer_get_key()<=0){ 1818 (!f || getch2(20)<=0) && mplayer_get_key()<=0){
1666 video_out->check_events(); 1819 video_out->check_events();
1667 if(!f) usleep(1000); // do not eat the CPU 1820 if(!f) usleep(1000); // do not eat the CPU
1668 } 1821 }
1669 osd_function=OSD_PLAY; 1822 osd_function=OSD_PLAY;
1823 #ifdef HAVE_GUI
1824 } else while( osd_function != OSD_PLAY ) usleep( 1000 );
1825 #endif
1670 } 1826 }
1671 1827
1672 } // while(v_frame<a_frame || force_redraw) 1828 } // while(v_frame<a_frame || force_redraw)
1673 1829
1674 1830
1675 //================= Keyboard events, SEEKing ==================== 1831 //================= Keyboard events, SEEKing ====================
1676 1832
1677 { int rel_seek_secs=0; 1833 { int c;
1678 int c;
1679 while( 1834 while(
1680 #ifdef HAVE_LIRC 1835 #ifdef HAVE_LIRC
1681 (c=lirc_mp_getinput())>0 || 1836 (c=lirc_mp_getinput())>0 ||
1682 #endif 1837 #endif
1683 (f && (c=getch2(0))>0) || (c=mplayer_get_key())>0) switch(c){ 1838 (f && (c=getch2(0))>0) || (c=mplayer_get_key())>0) switch(c){
2039 v_frame=0; // !!!!!! 2194 v_frame=0; // !!!!!!
2040 audio_time_usage=0; video_time_usage=0; vout_time_usage=0; 2195 audio_time_usage=0; video_time_usage=0; vout_time_usage=0;
2041 // num_frames=real_num_frames=0; 2196 // num_frames=real_num_frames=0;
2042 2197
2043 } 2198 }
2199 rel_seek_secs=0;
2044 } // keyboard event handler 2200 } // keyboard event handler
2045 2201
2046 //================= Update OSD ==================== 2202 //================= Update OSD ====================
2047 { int i; 2203 { int i;
2048 if(osd_level>=2){ 2204 if(osd_level>=2){