From ac7ecbe30cdec598955471d2ed012f36296b78de Mon Sep 17 00:00:00 2001 From: James Ross-Gowan Date: Sun, 29 Mar 2015 22:36:46 +1100 Subject: win32: use a platform-specific unicode entry-point Add a platform-specific entry-point for Windows. This will allow some platform-specific initialization to be added without the need for ugly ifdeffery in main.c. As an immediate advantage, mpv can now use a unicode entry-point and convert the command line arguments to UTF-8 before passing them to mpv_main, so osdep_preinit can be simplified a little bit. --- player/main-fn-unix.c | 15 +++++++++++++++ player/main-fn-win.c | 20 ++++++++++++++++++++ player/main.c | 12 ++++-------- player/main_fn.c | 15 --------------- 4 files changed, 39 insertions(+), 23 deletions(-) create mode 100644 player/main-fn-unix.c create mode 100644 player/main-fn-win.c delete mode 100644 player/main_fn.c (limited to 'player') diff --git a/player/main-fn-unix.c b/player/main-fn-unix.c new file mode 100644 index 0000000000..23a047b4dc --- /dev/null +++ b/player/main-fn-unix.c @@ -0,0 +1,15 @@ +#include "config.h" +#include "core.h" + +#if HAVE_COCOA_APPLICATION +#include "osdep/macosx_application.h" +#endif + +int main(int argc, char *argv[]) +{ +#if HAVE_COCOA_APPLICATION + return cocoa_main(mpv_main, argc, argv); +#else + return mpv_main(argc, argv); +#endif +} diff --git a/player/main-fn-win.c b/player/main-fn-win.c new file mode 100644 index 0000000000..125b4116f8 --- /dev/null +++ b/player/main-fn-win.c @@ -0,0 +1,20 @@ +#include "config.h" +#include "core.h" +#include "osdep/io.h" + +int wmain(int argc, wchar_t *argv[]); + +// mpv does its own wildcard expansion in the option parser +int _dowildcard = 0; + +int wmain(int argc, wchar_t *argv[]) +{ + char **argv_u8 = talloc_zero_array(NULL, char*, argc + 1); + for (int i = 0; i < argc; i++) + argv_u8[i] = mp_to_utf8(argv_u8, argv[i]); + + int ret = mpv_main(argc, argv_u8); + + talloc_free(argv_u8); + return ret; +} diff --git a/player/main.c b/player/main.c index c517e871f6..55f5ff623b 100644 --- a/player/main.c +++ b/player/main.c @@ -275,19 +275,15 @@ static bool handle_help_options(struct MPContext *mpctx) return opt_exit; } -static void osdep_preinit(int *p_argc, char ***p_argv) +static void osdep_preinit(int argc, char **argv) { char *enable_talloc = getenv("MPV_LEAK_REPORT"); - if (*p_argc > 1 && (strcmp((*p_argv)[1], "-leak-report") == 0 || - strcmp((*p_argv)[1], "--leak-report") == 0)) + if (argc > 1 && (strcmp(argv[1], "-leak-report") == 0 || + strcmp(argv[1], "--leak-report") == 0)) enable_talloc = "1"; if (enable_talloc && strcmp(enable_talloc, "1") == 0) talloc_enable_leak_report(); -#ifdef __MINGW32__ - mp_get_converted_argv(p_argc, p_argv); -#endif - #ifdef _WIN32 // stop Windows from showing all kinds of annoying error dialogs SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX); @@ -514,7 +510,7 @@ int mp_initialize(struct MPContext *mpctx, char **options) int mpv_main(int argc, char *argv[]) { - osdep_preinit(&argc, &argv); + osdep_preinit(argc, argv); struct MPContext *mpctx = mp_create(); struct MPOpts *opts = mpctx->opts; diff --git a/player/main_fn.c b/player/main_fn.c deleted file mode 100644 index 23a047b4dc..0000000000 --- a/player/main_fn.c +++ /dev/null @@ -1,15 +0,0 @@ -#include "config.h" -#include "core.h" - -#if HAVE_COCOA_APPLICATION -#include "osdep/macosx_application.h" -#endif - -int main(int argc, char *argv[]) -{ -#if HAVE_COCOA_APPLICATION - return cocoa_main(mpv_main, argc, argv); -#else - return mpv_main(argc, argv); -#endif -} -- cgit v1.2.3