summaryrefslogtreecommitdiffstats
path: root/player
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-05-02 18:47:57 +0200
committerDiogo Franco (Kovensky) <diogomfranco@gmail.com>2015-05-07 10:45:33 +0900
commit26e779c9aa74b84e50d4ca2ea14adf4bc1d961ac (patch)
tree6f288a39aa5a38e1144c5e16cbe2b5337882bb6c /player
parentfe19db9cc08b96c813987e937bdc6f19a6d629f9 (diff)
downloadmpv-26e779c9aa74b84e50d4ca2ea14adf4bc1d961ac.tar.bz2
mpv-26e779c9aa74b84e50d4ca2ea14adf4bc1d961ac.tar.xz
build: move main-fn files to osdep
And split the Cocoa and Unix cases. Simplify the Cocoa case slightly by calling mpv_main directly, instead of passing a function pointer. Also add a comment explaining why Cocoa needs a special case at all. (cherry picked from commit 1e7831070f6ae1af0a1a29b0d680ef2907bf8cf6)
Diffstat (limited to 'player')
-rw-r--r--player/core.h1
-rw-r--r--player/main-fn-unix.c15
-rw-r--r--player/main-fn-win.c55
-rw-r--r--player/main.c1
4 files changed, 1 insertions, 71 deletions
diff --git a/player/core.h b/player/core.h
index da9401be36..ea7694d02a 100644
--- a/player/core.h
+++ b/player/core.h
@@ -404,7 +404,6 @@ struct track *select_track(struct MPContext *mpctx, enum stream_type type,
int tid, int ffid, char **langs);
// main.c
-int mpv_main(int argc, char *argv[]);
int mp_initialize(struct MPContext *mpctx, char **argv);
struct MPContext *mp_create(void);
void mp_destroy(struct MPContext *mpctx);
diff --git a/player/main-fn-unix.c b/player/main-fn-unix.c
deleted file mode 100644
index 87e1681987..0000000000
--- a/player/main-fn-unix.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include "config.h"
-#include "core.h"
-
-#if HAVE_COCOA
-#include "osdep/macosx_application.h"
-#endif
-
-int main(int argc, char *argv[])
-{
-#if HAVE_COCOA
- 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
deleted file mode 100644
index 28fc5b3c24..0000000000
--- a/player/main-fn-win.c
+++ /dev/null
@@ -1,55 +0,0 @@
-#include <windows.h>
-
-#include "config.h"
-
-#include "osdep/io.h"
-#include "osdep/terminal.h"
-
-#include "core.h"
-
-int wmain(int argc, wchar_t *argv[]);
-
-// mpv does its own wildcard expansion in the option parser
-int _dowildcard = 0;
-
-static bool is_valid_handle(HANDLE h)
-{
- return h != INVALID_HANDLE_VALUE && h != NULL &&
- GetFileType(h) != FILE_TYPE_UNKNOWN;
-}
-
-static bool has_redirected_stdio(void)
-{
- return is_valid_handle(GetStdHandle(STD_INPUT_HANDLE)) ||
- is_valid_handle(GetStdHandle(STD_OUTPUT_HANDLE)) ||
- is_valid_handle(GetStdHandle(STD_ERROR_HANDLE));
-}
-
-int wmain(int argc, wchar_t *argv[])
-{
- // If started from the console wrapper (see osdep/win32-console-wrapper.c),
- // attach to the console and set up the standard IO handles
- bool has_console = terminal_try_attach();
-
- // If mpv is started from Explorer, the Run dialog or the Start Menu, it
- // will have no console and no standard IO handles. In this case, the user
- // is expecting mpv to show some UI, so enable the pseudo-GUI profile.
- bool gui = !has_console && !has_redirected_stdio();
-
- int argv_len = 0;
- char **argv_u8 = NULL;
-
- // Build mpv's UTF-8 argv, and add the pseudo-GUI profile if necessary
- if (argv[0])
- MP_TARRAY_APPEND(NULL, argv_u8, argv_len, mp_to_utf8(argv_u8, argv[0]));
- if (gui)
- MP_TARRAY_APPEND(NULL, argv_u8, argv_len, "--profile=pseudo-gui");
- for (int i = 1; i < argc; i++)
- MP_TARRAY_APPEND(NULL, argv_u8, argv_len, mp_to_utf8(argv_u8, argv[i]));
- MP_TARRAY_APPEND(NULL, argv_u8, argv_len, NULL);
-
- int ret = mpv_main(argv_len - 1, argv_u8);
-
- talloc_free(argv_u8);
- return ret;
-}
diff --git a/player/main.c b/player/main.c
index 1d56f0ceda..3719f2156a 100644
--- a/player/main.c
+++ b/player/main.c
@@ -30,6 +30,7 @@
#include "osdep/io.h"
#include "osdep/terminal.h"
#include "osdep/timer.h"
+#include "osdep/main-fn.h"
#include "common/av_log.h"
#include "common/codecs.h"