Mercurial > mplayer.hg
comparison mplayer.c @ 32383:f6e78eef2e1b
Avoid duplicating common init code between MPlayer and mencoder.
author | reimar |
---|---|
date | Sat, 09 Oct 2010 15:04:50 +0000 |
parents | 9a5340bb1f69 |
children | d1f6c6cf8905 |
comparison
equal
deleted
inserted
replaced
32382:9a5340bb1f69 | 32383:f6e78eef2e1b |
---|---|
112 #include "mp_fifo.h" | 112 #include "mp_fifo.h" |
113 #include "mp_msg.h" | 113 #include "mp_msg.h" |
114 #include "mpcommon.h" | 114 #include "mpcommon.h" |
115 #include "mplayer.h" | 115 #include "mplayer.h" |
116 #include "osdep/getch2.h" | 116 #include "osdep/getch2.h" |
117 #include "osdep/priority.h" | |
118 #include "osdep/timer.h" | 117 #include "osdep/timer.h" |
119 #include "parser-cfg.h" | 118 #include "parser-cfg.h" |
120 #include "parser-mpcmd.h" | 119 #include "parser-mpcmd.h" |
121 #include "path.h" | 120 #include "path.h" |
122 #include "playtree.h" | 121 #include "playtree.h" |
2732 * file for some tools to link against. */ | 2731 * file for some tools to link against. */ |
2733 #ifndef DISABLE_MAIN | 2732 #ifndef DISABLE_MAIN |
2734 int main(int argc,char* argv[]){ | 2733 int main(int argc,char* argv[]){ |
2735 | 2734 |
2736 | 2735 |
2737 char * mem_ptr; | |
2738 | |
2739 // movie info: | 2736 // movie info: |
2740 | 2737 |
2741 /* Flag indicating whether MPlayer should exit without playing anything. */ | 2738 /* Flag indicating whether MPlayer should exit without playing anything. */ |
2742 int opt_exit = 0; | 2739 int opt_exit = 0; |
2743 int i; | 2740 int i; |
2744 | 2741 |
2745 int gui_no_filename=0; | 2742 int gui_no_filename=0; |
2746 | 2743 |
2747 InitTimer(); | 2744 common_preinit(); |
2748 srand(GetTimerMS()); | |
2749 | |
2750 mp_msg_init(); | |
2751 | 2745 |
2752 // Create the config context and register the options | 2746 // Create the config context and register the options |
2753 mconfig = m_config_new(); | 2747 mconfig = m_config_new(); |
2754 m_config_register_options(mconfig,mplayer_opts); | 2748 m_config_register_options(mconfig,mplayer_opts); |
2755 m_config_register_options(mconfig, common_opts); | 2749 m_config_register_options(mconfig, common_opts); |
2756 mp_input_register_options(mconfig); | 2750 mp_input_register_options(mconfig); |
2757 | 2751 |
2758 // Preparse the command line | 2752 // Preparse the command line |
2759 m_config_preparse_command_line(mconfig,argc,argv); | 2753 m_config_preparse_command_line(mconfig,argc,argv); |
2760 | |
2761 #if (defined(__MINGW32__) || defined(__CYGWIN__)) && defined(CONFIG_WIN32DLL) | |
2762 set_path_env(); | |
2763 #endif | |
2764 | 2754 |
2765 #ifdef CONFIG_TV | 2755 #ifdef CONFIG_TV |
2766 stream_tv_defaults.immediate = 1; | 2756 stream_tv_defaults.immediate = 1; |
2767 #endif | 2757 #endif |
2768 | 2758 |
2803 } | 2793 } |
2804 } | 2794 } |
2805 } | 2795 } |
2806 | 2796 |
2807 print_version("MPlayer"); | 2797 print_version("MPlayer"); |
2808 | 2798 if (!common_init()) |
2809 #if defined(__MINGW32__) || defined(__CYGWIN__) | 2799 exit_player_with_rc(EXIT_NONE, 0); |
2810 #ifdef CONFIG_GUI | |
2811 void *runningmplayer = FindWindow("MPlayer GUI for Windows", "MPlayer for Windows"); | |
2812 if(runningmplayer && filename && use_gui){ | |
2813 COPYDATASTRUCT csData; | |
2814 char file[MAX_PATH]; | |
2815 char *filepart = filename; | |
2816 if(GetFullPathName(filename, MAX_PATH, file, &filepart)){ | |
2817 csData.dwData = 0; | |
2818 csData.cbData = strlen(file)*2; | |
2819 csData.lpData = file; | |
2820 SendMessage(runningmplayer, WM_COPYDATA, (WPARAM)runningmplayer, (LPARAM)&csData); | |
2821 } | |
2822 } | |
2823 #endif | |
2824 | |
2825 { | |
2826 HMODULE kernel32 = GetModuleHandle("Kernel32.dll"); | |
2827 BOOL WINAPI (*setDEP)(DWORD) = NULL; | |
2828 BOOL WINAPI (*setDllDir)(LPCTSTR) = NULL; | |
2829 if (kernel32) { | |
2830 setDEP = GetProcAddress(kernel32, "SetProcessDEPPolicy"); | |
2831 setDllDir = GetProcAddress(kernel32, "SetDllDirectoryA"); | |
2832 } | |
2833 if (setDEP) setDEP(3); | |
2834 if (setDllDir) setDllDir(""); | |
2835 } | |
2836 // stop Windows from showing all kinds of annoying error dialogs | |
2837 SetErrorMode(0x8003); | |
2838 // request 1ms timer resolution | |
2839 timeBeginPeriod(1); | |
2840 #endif | |
2841 | |
2842 #ifdef CONFIG_PRIORITY | |
2843 set_priority(); | |
2844 #endif | |
2845 | |
2846 if (codec_path) | |
2847 set_codec_path(codec_path); | |
2848 | 2800 |
2849 #ifndef CONFIG_GUI | 2801 #ifndef CONFIG_GUI |
2850 if(use_gui){ | 2802 if(use_gui){ |
2851 mp_msg(MSGT_CPLAYER,MSGL_WARN,MSGTR_NoGui); | 2803 mp_msg(MSGT_CPLAYER,MSGL_WARN,MSGTR_NoGui); |
2852 use_gui=0; | 2804 use_gui=0; |
2883 if(audio_driver_list && strcmp(audio_driver_list[0],"help")==0){ | 2835 if(audio_driver_list && strcmp(audio_driver_list[0],"help")==0){ |
2884 list_audio_out(); | 2836 list_audio_out(); |
2885 opt_exit = 1; | 2837 opt_exit = 1; |
2886 } | 2838 } |
2887 | 2839 |
2888 /* Check codecs.conf. */ | |
2889 if(!codecs_file || !parse_codec_cfg(codecs_file)){ | |
2890 if(!parse_codec_cfg(mem_ptr=get_path("codecs.conf"))){ | |
2891 if(!parse_codec_cfg(MPLAYER_CONFDIR "/codecs.conf")){ | |
2892 if(!parse_codec_cfg(NULL)){ | |
2893 exit_player_with_rc(EXIT_NONE, 0); | |
2894 } | |
2895 mp_msg(MSGT_CPLAYER,MSGL_V,MSGTR_BuiltinCodecsConf); | |
2896 } | |
2897 } | |
2898 free( mem_ptr ); // release the buffer created by get_path() | |
2899 } | |
2900 | |
2901 if(audio_codec_list && strcmp(audio_codec_list[0],"help")==0){ | 2840 if(audio_codec_list && strcmp(audio_codec_list[0],"help")==0){ |
2902 mp_msg(MSGT_CPLAYER, MSGL_INFO, MSGTR_AvailableAudioCodecs); | 2841 mp_msg(MSGT_CPLAYER, MSGL_INFO, MSGTR_AvailableAudioCodecs); |
2903 mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_AUDIO_CODECS\n"); | 2842 mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_AUDIO_CODECS\n"); |
2904 list_codecs(1); | 2843 list_codecs(1); |
2905 mp_msg(MSGT_FIXME, MSGL_FIXME, "\n"); | 2844 mp_msg(MSGT_FIXME, MSGL_FIXME, "\n"); |
2971 for(i=1;i<argc;i++)mp_msg(MSGT_CPLAYER, MSGL_INFO," '%s'",argv[i]); | 2910 for(i=1;i<argc;i++)mp_msg(MSGT_CPLAYER, MSGL_INFO," '%s'",argv[i]); |
2972 mp_msg(MSGT_CPLAYER, MSGL_INFO, "\n"); | 2911 mp_msg(MSGT_CPLAYER, MSGL_INFO, "\n"); |
2973 } | 2912 } |
2974 | 2913 |
2975 //------ load global data first ------ | 2914 //------ load global data first ------ |
2976 | |
2977 // check font | |
2978 #ifdef CONFIG_FREETYPE | |
2979 init_freetype(); | |
2980 #endif | |
2981 #ifdef CONFIG_FONTCONFIG | |
2982 if(font_fontconfig <= 0) | |
2983 { | |
2984 #endif | |
2985 #ifdef CONFIG_BITMAP_FONT | |
2986 if(font_name){ | |
2987 vo_font=read_font_desc(font_name,font_factor,verbose>1); | |
2988 if(!vo_font) mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_CantLoadFont, | |
2989 filename_recode(font_name)); | |
2990 } else { | |
2991 // try default: | |
2992 vo_font=read_font_desc( mem_ptr=get_path("font/font.desc"),font_factor,verbose>1); | |
2993 free(mem_ptr); // release the buffer created by get_path() | |
2994 if(!vo_font) | |
2995 vo_font=read_font_desc(MPLAYER_DATADIR "/font/font.desc",font_factor,verbose>1); | |
2996 } | |
2997 if (sub_font_name) | |
2998 sub_font = read_font_desc(sub_font_name, font_factor, verbose>1); | |
2999 else | |
3000 sub_font = vo_font; | |
3001 #endif | |
3002 #ifdef CONFIG_FONTCONFIG | |
3003 } | |
3004 #endif | |
3005 | |
3006 vo_init_osd(); | |
3007 | |
3008 #ifdef CONFIG_ASS | |
3009 ass_library = ass_init(); | |
3010 #endif | |
3011 | 2915 |
3012 #ifdef HAVE_RTC | 2916 #ifdef HAVE_RTC |
3013 if(!nortc) | 2917 if(!nortc) |
3014 { | 2918 { |
3015 // seteuid(0); /* Can't hurt to try to get root here */ | 2919 // seteuid(0); /* Can't hurt to try to get root here */ |