comparison mplayer.c @ 5983:4d868c3c9fff

some cleanup around uninit()
author arpi
date Sun, 05 May 2002 17:22:38 +0000
parents caac20b1ca79
children 7f6e02a16ac4
comparison
equal deleted inserted replaced
5982:b61b22fbcd08 5983:4d868c3c9fff
747 signal(SIGILL,exit_sighandler); // illegal instruction 747 signal(SIGILL,exit_sighandler); // illegal instruction
748 signal(SIGFPE,exit_sighandler); // floating point exc. 748 signal(SIGFPE,exit_sighandler); // floating point exc.
749 signal(SIGABRT,exit_sighandler); // abort() 749 signal(SIGABRT,exit_sighandler); // abort()
750 #endif 750 #endif
751 751
752 // ******************* Now, let's see the per-file stuff ********************
753
754 #ifdef HAVE_NEW_GUI 752 #ifdef HAVE_NEW_GUI
755 if(use_gui){ 753 if(use_gui){
756 guiInit( argc,argv,envp ); 754 guiInit( argc,argv,envp );
757 inited_flags|=INITED_GUI; 755 inited_flags|=INITED_GUI;
758 guiGetEvent( guiCEvent,(char *)((gui_no_filename) ? 0 : 1) ); 756 guiGetEvent( guiCEvent,(char *)((gui_no_filename) ? 0 : 1) );
759 } 757 }
760 #endif 758 #endif
761 759
760 // ******************* Now, let's see the per-file stuff ********************
761
762 play_next_file: 762 play_next_file:
763 763
764 // We must enable getch2 here to be able to interrupt network connection 764 // We must enable getch2 here to be able to interrupt network connection
765 // or cache filling 765 // or cache filling
766 if(!use_stdin && !slave_mode){ 766 if(!use_stdin && !slave_mode){
767 getch2_enable(); // prepare stdin for hotkeys... 767 if(inited_flags&INITED_GETCH2)
768 mp_msg(MSGT_CPLAYER,MSGL_WARN,"WARNING: getch2_init called twice!\n");
769 else
770 getch2_enable(); // prepare stdin for hotkeys...
768 inited_flags|=INITED_GETCH2; 771 inited_flags|=INITED_GETCH2;
769 mp_msg(MSGT_CPLAYER,MSGL_DBG2,"\n[[[init getch2]]]\n"); 772 mp_msg(MSGT_CPLAYER,MSGL_DBG2,"\n[[[init getch2]]]\n");
770 } 773 }
771 774
775 // =================== GUI idle loop (STOP state) ===========================
772 #ifdef HAVE_NEW_GUI 776 #ifdef HAVE_NEW_GUI
773 if ( use_gui ) { 777 if ( use_gui ) {
774 778
775 guiGetEvent( guiReDrawSubWindow,0 ); 779 guiGetEvent( guiReDrawSubWindow,0 );
776 while ( guiIntfStruct.Playing != 1 ) 780 while ( guiIntfStruct.Playing != 1 )
777 { 781 {
778 #ifdef HAVE_NEW_INPUT 782 #ifdef HAVE_NEW_INPUT
779 mp_cmd_t* cmd; 783 mp_cmd_t* cmd;
780 #endif 784 #endif
781 usleep(20000); 785 usleep(40000);
782 guiEventHandling(); 786 guiEventHandling();
783 #ifdef HAVE_NEW_INPUT 787 #ifdef HAVE_NEW_INPUT
784 if ( (cmd = mp_input_get_cmd(0,0)) != NULL) guiGetEvent( guiIEvent,(char *)cmd->id ); 788 if ( (cmd = mp_input_get_cmd(0,0)) != NULL) guiGetEvent( guiIEvent,(char *)cmd->id );
785 #endif 789 #endif
786 } 790 }
827 } 831 }
828 guiIntfStruct.FilenameChanged=0; 832 guiIntfStruct.FilenameChanged=0;
829 } 833 }
830 } 834 }
831 #endif 835 #endif
836 //---------------------------------------------------------------------------
832 837
833 if(filename) mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_Playing, filename); 838 if(filename) mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_Playing, filename);
839
840 //==================== Open VOB-Sub ============================
834 841
835 current_module="vobsub"; 842 current_module="vobsub";
836 if (vobsub_name){ 843 if (vobsub_name){
837 vo_vobsub=vobsub_open(vobsub_name,1); 844 vo_vobsub=vobsub_open(vobsub_name,1);
838 if(vo_vobsub==NULL) 845 if(vo_vobsub==NULL)
846 free(buf); 853 free(buf);
847 } 854 }
848 if(vo_vobsub) 855 if(vo_vobsub)
849 sub_auto=0; // don't do autosub for textsubs if vobsub found 856 sub_auto=0; // don't do autosub for textsubs if vobsub found
850 857
851 stream=NULL; 858 //==================== Init Video Out ============================
852 demuxer=NULL;
853 d_audio=NULL;
854 d_video=NULL;
855 sh_audio=NULL;
856 sh_video=NULL;
857 859
858 // check video_out driver name: 860 // check video_out driver name:
859 if (video_driver) 861 if (video_driver)
860 if ((i = strcspn(video_driver, ":")) > 0) 862 if ((i = strcspn(video_driver, ":")) > 0)
861 { 863 {
882 884
883 if(!video_out){ 885 if(!video_out){
884 mp_msg(MSGT_CPLAYER,MSGL_FATAL,MSGTR_InvalidVOdriver,video_driver?video_driver:"?"); 886 mp_msg(MSGT_CPLAYER,MSGL_FATAL,MSGTR_InvalidVOdriver,video_driver?video_driver:"?");
885 exit_player(MSGTR_Exit_error); 887 exit_player(MSGTR_Exit_error);
886 } 888 }
889
890 //==================== Init Audio Out ============================
891
887 // check audio_out driver name: 892 // check audio_out driver name:
888 if (audio_driver) 893 if (audio_driver)
889 if ((i = strcspn(audio_driver, ":")) > 0) 894 if ((i = strcspn(audio_driver, ":")) > 0)
890 { 895 {
891 size_t i2 = strlen(audio_driver); 896 size_t i2 = strlen(audio_driver);
923 } 928 }
924 } 929 }
925 } 930 }
926 931
927 //============ Open & Sync STREAM --- fork cache2 ==================== 932 //============ Open & Sync STREAM --- fork cache2 ====================
933
934 stream=NULL;
935 demuxer=NULL;
936 d_audio=NULL;
937 d_video=NULL;
938 sh_audio=NULL;
939 sh_video=NULL;
928 940
929 current_module="open_stream"; 941 current_module="open_stream";
930 stream=open_stream(filename,vcd_track,&file_format); 942 stream=open_stream(filename,vcd_track,&file_format);
931 if(!stream) { // error... 943 if(!stream) { // error...
932 eof = libmpdemux_was_interrupted(PT_NEXT_ENTRY); 944 eof = libmpdemux_was_interrupted(PT_NEXT_ENTRY);
2927 100.0*video_time_usage/total_time_usage, 2939 100.0*video_time_usage/total_time_usage,
2928 100.0*vout_time_usage/total_time_usage, 2940 100.0*vout_time_usage/total_time_usage,
2929 100.0*audio_time_usage/total_time_usage, 2941 100.0*audio_time_usage/total_time_usage,
2930 100.0*(total_time_usage-tot)/total_time_usage, 2942 100.0*(total_time_usage-tot)/total_time_usage,
2931 100.0); 2943 100.0);
2932 if(total_frame_cnt) 2944 if(total_frame_cnt && frame_dropping)
2933 mp_msg(MSGT_CPLAYER,MSGL_INFO,"BENCHMARKn: disp: %d (%3.2f fps) drop: %d (%d%%) total: %d (%3.2f fps)\n", 2945 mp_msg(MSGT_CPLAYER,MSGL_INFO,"BENCHMARKn: disp: %d (%3.2f fps) drop: %d (%d%%) total: %d (%3.2f fps)\n",
2934 total_frame_cnt-drop_frame_cnt, 2946 total_frame_cnt-drop_frame_cnt,
2935 (total_time_usage>0.5)?((total_frame_cnt-drop_frame_cnt)/total_time_usage):0, 2947 (total_time_usage>0.5)?((total_frame_cnt-drop_frame_cnt)/total_time_usage):0,
2936 drop_frame_cnt, 2948 drop_frame_cnt,
2937 100*drop_frame_cnt/total_frame_cnt, 2949 100*drop_frame_cnt/total_frame_cnt,
2938 total_frame_cnt, 2950 total_frame_cnt,
2939 (total_time_usage>0.5)?(total_frame_cnt/total_time_usage):0); 2951 (total_time_usage>0.5)?(total_frame_cnt/total_time_usage):0);
2940 2952
2941 } 2953 }
2942 2954
2943 uninit_player(INITED_VO|INITED_AO); 2955 // time to uninit all, except global stuff:
2956 uninit_player(INITED_ALL-(INITED_GUI+INITED_LIRC+INITED_INPUT));
2944 2957
2945 if(eof == PT_NEXT_ENTRY || eof == PT_PREV_ENTRY) { 2958 if(eof == PT_NEXT_ENTRY || eof == PT_PREV_ENTRY) {
2946 eof = eof == PT_NEXT_ENTRY ? 1 : -1; 2959 eof = eof == PT_NEXT_ENTRY ? 1 : -1;
2947 if(play_tree_iter_step(playtree_iter,eof,0) == PLAY_TREE_ITER_ENTRY) { 2960 if(play_tree_iter_step(playtree_iter,eof,0) == PLAY_TREE_ITER_ENTRY) {
2948 uninit_player(INITED_ALL-(INITED_GUI+INITED_LIRC+INITED_INPUT));
2949 eof = 1; 2961 eof = 1;
2950 } else { 2962 } else {
2951 play_tree_iter_free(playtree_iter); 2963 play_tree_iter_free(playtree_iter);
2952 playtree_iter = NULL; 2964 playtree_iter = NULL;
2953 } 2965 }
2954 } else if (eof == PT_UP_NEXT || eof == PT_UP_PREV) { 2966 } else if (eof == PT_UP_NEXT || eof == PT_UP_PREV) {
2955 eof = eof == PT_UP_NEXT ? 1 : -1; 2967 eof = eof == PT_UP_NEXT ? 1 : -1;
2956 if(play_tree_iter_up_step(playtree_iter,eof,0) == PLAY_TREE_ITER_ENTRY) { 2968 if(play_tree_iter_up_step(playtree_iter,eof,0) == PLAY_TREE_ITER_ENTRY) {
2957 uninit_player(INITED_ALL-(INITED_GUI+INITED_LIRC+INITED_INPUT));
2958 eof = 1; 2969 eof = 1;
2959 } else { 2970 } else {
2960 play_tree_iter_free(playtree_iter); 2971 play_tree_iter_free(playtree_iter);
2961 playtree_iter = NULL; 2972 playtree_iter = NULL;
2962 } 2973 }
2963 } else { // NEXT PREV SRC 2974 } else { // NEXT PREV SRC
2964 uninit_player(INITED_ALL-(INITED_GUI+INITED_LIRC+INITED_INPUT));
2965 eof = eof == PT_PREV_SRC ? -1 : 1; 2975 eof = eof == PT_PREV_SRC ? -1 : 1;
2966 } 2976 }
2967 2977
2968 if(eof == 0) eof = 1; 2978 if(eof == 0) eof = 1;
2969 2979
2987 mplStop(); 2997 mplStop();
2988 } 2998 }
2989 #endif 2999 #endif
2990 3000
2991 if(use_gui || playtree_iter != NULL 3001 if(use_gui || playtree_iter != NULL
2992 #if defined( HAVE_NEW_GUI ) && defined( USE_DVDREAD ) 3002 // once use_gui is set, this won't be reached -> useless: --A'rpi
2993 || ( guiIntfStruct.DVDChanged && use_gui ) 3003 //#if defined( HAVE_NEW_GUI ) && defined( USE_DVDREAD )
2994 #endif 3004 // || ( guiIntfStruct.DVDChanged && use_gui )
3005 //#endif
2995 ){ 3006 ){
2996 3007
2997 current_module="uninit_acodec"; 3008 current_module="uninit_acodec";
2998 if(sh_audio) uninit_audio(sh_audio); 3009 if(sh_audio) uninit_audio(sh_audio);
2999 sh_audio=NULL; 3010 sh_audio=NULL;