diff options
author | wm4 <wm4@nowhere> | 2012-08-03 05:09:55 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2012-08-03 05:09:55 +0200 |
commit | 11648493db7db164aa8fe01751b7e5c5e5faa810 (patch) | |
tree | c09ca2657dd1c5e0ddedd1dc52880557cb774073 /mplayer.c | |
parent | 4ced6d4e78d5f8304af8f36276c01789450491cd (diff) | |
download | mpv-11648493db7db164aa8fe01751b7e5c5e5faa810.tar.bz2 mpv-11648493db7db164aa8fe01751b7e5c5e5faa810.tar.xz |
mplayer: move highly OS specific initialization code out of main()
The intention is to make the main() function smaller (which is at
about 1000 lines currently).
This commit also changes the order of some initializations, but that
should be safe.
Diffstat (limited to 'mplayer.c')
-rw-r--r-- | mplayer.c | 91 |
1 files changed, 47 insertions, 44 deletions
@@ -3424,27 +3424,62 @@ static void detach_ptw32(void) } #endif -/* This preprocessor directive is a hack to generate a mplayer-nomain.o object - * file for some tools to link against. */ -#ifndef DISABLE_MAIN -int main(int argc, char *argv[]) +static void osdep_preinit(int *p_argc, char ***p_argv) { + GetCpuCaps(&gCpuCaps); + +#ifdef __MINGW32__ + mp_get_converted_argv(&argc, &argv); +#endif + #ifdef PTW32_STATIC_LIB pthread_win32_process_attach_np(); pthread_win32_thread_attach_np(); atexit(detach_ptw32); #endif - if (argc > 1 && (!strcmp(argv[1], "-leak-report") - || !strcmp(argv[1], "--leak-report"))) - talloc_enable_leak_report(); -#ifdef __MINGW32__ - mp_get_converted_argv(&argc, &argv); + InitTimer(); + srand(GetTimerMS()); + +#if (defined(__MINGW32__) || defined(__CYGWIN__)) && defined(CONFIG_WIN32DLL) + set_path_env(); +#endif + +#if defined(__MINGW32__) || defined(__CYGWIN__) + { + HMODULE kernel32 = GetModuleHandle("Kernel32.dll"); + BOOL WINAPI (*setDEP)(DWORD) = NULL; + BOOL WINAPI (*setDllDir)(LPCTSTR) = NULL; + if (kernel32) { + setDEP = GetProcAddress(kernel32, "SetProcessDEPPolicy"); + setDllDir = GetProcAddress(kernel32, "SetDllDirectoryA"); + } + if (setDEP) + setDEP(3); + if (setDllDir) + setDllDir(""); + } + // stop Windows from showing all kinds of annoying error dialogs + SetErrorMode(0x8003); + // request 1ms timer resolution + timeBeginPeriod(1); +#endif + +#ifdef HAVE_TERMCAP + load_termcap(NULL); // load key-codes #endif +} - char *mem_ptr; +/* This preprocessor directive is a hack to generate a mplayer-nomain.o object + * file for some tools to link against. */ +#ifndef DISABLE_MAIN +int main(int argc, char *argv[]) +{ + osdep_preinit(&argc, &argv); - // movie info: + if (argc > 1 && (!strcmp(argv[1], "-leak-report") + || !strcmp(argv[1], "--leak-report"))) + talloc_enable_leak_report(); /* Flag indicating whether MPlayer should exit without playing anything. */ int opt_exit = 0; @@ -3461,9 +3496,6 @@ int main(int argc, char *argv[]) .terminal_osd_text = talloc_strdup(mpctx, ""), }; - InitTimer(); - srand(GetTimerMS()); - mp_msg_init(); init_libav(); screenshot_init(mpctx); @@ -3485,12 +3517,6 @@ int main(int argc, char *argv[]) print_version(false); print_libav_versions(); - GetCpuCaps(&gCpuCaps); - -#if (defined(__MINGW32__) || defined(__CYGWIN__)) && defined(CONFIG_WIN32DLL) - set_path_env(); -#endif - parse_cfgfiles(mpctx, mpctx->mconfig); mpctx->playlist = talloc_struct(mpctx, struct playlist, {0}); @@ -3502,26 +3528,6 @@ int main(int argc, char *argv[]) opt_exit = 1; } -#if defined(__MINGW32__) || defined(__CYGWIN__) - { - HMODULE kernel32 = GetModuleHandle("Kernel32.dll"); - BOOL WINAPI (*setDEP)(DWORD) = NULL; - BOOL WINAPI (*setDllDir)(LPCTSTR) = NULL; - if (kernel32) { - setDEP = GetProcAddress(kernel32, "SetProcessDEPPolicy"); - setDllDir = GetProcAddress(kernel32, "SetDllDirectoryA"); - } - if (setDEP) - setDEP(3); - if (setDllDir) - setDllDir(""); - } - // stop Windows from showing all kinds of annoying error dialogs - SetErrorMode(0x8003); - // request 1ms timer resolution - timeBeginPeriod(1); -#endif - #ifdef CONFIG_PRIORITY set_priority(); #endif @@ -3540,6 +3546,7 @@ int main(int argc, char *argv[]) /* Check codecs.conf. */ if (!codecs_file || !parse_codec_cfg(codecs_file)) { + char *mem_ptr; if (!parse_codec_cfg(mem_ptr = get_path("codecs.conf"))) { if (!parse_codec_cfg(MPLAYER_CONFDIR "/codecs.conf")) { if (!parse_codec_cfg(NULL)) @@ -3628,10 +3635,6 @@ int main(int argc, char *argv[]) mpctx->osd = osd_create(opts, mpctx->ass_library); -#ifdef HAVE_TERMCAP - load_termcap(NULL); // load key-codes -#endif - // ========== Init keyboard FIFO (connection to libvo) ============ // Init input system |