mirror of https://github.com/mpv-player/mpv
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.
This commit is contained in:
parent
19a5b20752
commit
1e7831070f
|
@ -335,7 +335,7 @@ all: $(ALL_TARGETS)
|
|||
%.o: %.c
|
||||
$(CC) $(DEPFLAGS) $(CFLAGS) -c -o $@ $<
|
||||
|
||||
mpv: $(OBJECTS) player/main-fn-unix.o
|
||||
mpv: $(OBJECTS) osdep/main-fn-unix.o
|
||||
$(CC) -o $@ $^ $(EXTRALIBS)
|
||||
|
||||
input/input.c: input/input_conf.h
|
||||
|
|
|
@ -18,8 +18,6 @@
|
|||
#ifndef MPV_MACOSX_APPLICATION
|
||||
#define MPV_MACOSX_APPLICATION
|
||||
|
||||
typedef int (*mpv_main_fn)(int, char**);
|
||||
|
||||
// Menu Keys identifing menu items
|
||||
typedef enum {
|
||||
MPM_H_SIZE,
|
||||
|
@ -30,7 +28,7 @@ typedef enum {
|
|||
} MPMenuKey;
|
||||
|
||||
// multithreaded wrapper for mpv_main
|
||||
int cocoa_main(mpv_main_fn mpv_main, int argc, char *argv[]);
|
||||
int cocoa_main(int argc, char *argv[]);
|
||||
void cocoa_register_menu_item_action(MPMenuKey key, void* action);
|
||||
|
||||
#endif /* MPV_MACOSX_APPLICATION */
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "osdep/macosx_compat.h"
|
||||
#import "osdep/macosx_events_objc.h"
|
||||
#include "osdep/threads.h"
|
||||
#include "osdep/main-fn.h"
|
||||
|
||||
#define MPV_PROTOCOL @"mpv://"
|
||||
|
||||
|
@ -252,7 +253,6 @@ static void terminate_cocoa_application(void)
|
|||
@end
|
||||
|
||||
struct playback_thread_ctx {
|
||||
mpv_main_fn mpv_main;
|
||||
int *argc;
|
||||
char ***argv;
|
||||
};
|
||||
|
@ -269,7 +269,7 @@ static void *playback_thread(void *ctx_obj)
|
|||
mpthread_set_name("playback core (OSX)");
|
||||
@autoreleasepool {
|
||||
struct playback_thread_ctx *ctx = (struct playback_thread_ctx*) ctx_obj;
|
||||
int r = ctx->mpv_main(*ctx->argc, *ctx->argv);
|
||||
int r = mpv_main(*ctx->argc, *ctx->argv);
|
||||
terminate_cocoa_application();
|
||||
// normally never reached - unless the cocoa mainloop hasn't started yet
|
||||
exit(r);
|
||||
|
@ -361,13 +361,12 @@ static bool bundle_started_from_finder(int argc, char **argv)
|
|||
}
|
||||
}
|
||||
|
||||
int cocoa_main(mpv_main_fn mpv_main, int argc, char *argv[])
|
||||
int cocoa_main(int argc, char *argv[])
|
||||
{
|
||||
@autoreleasepool {
|
||||
application_instantiated = true;
|
||||
|
||||
struct playback_thread_ctx ctx = {0};
|
||||
ctx.mpv_main = mpv_main;
|
||||
ctx.argc = &argc;
|
||||
ctx.argv = &argv;
|
||||
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
#include "osdep/macosx_application.h"
|
||||
|
||||
// This is needed because Cocoa absolutely requires creating the NSApplication
|
||||
// singleton and running it in the "main" thread. It is apparently not
|
||||
// possible to do this on a separate thread at all. It is not known how
|
||||
// Apple managed this colossal fuckup.
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
return cocoa_main(argc, argv);
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
#include "main-fn.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
return mpv_main(argc, argv);
|
||||
}
|
|
@ -2,10 +2,10 @@
|
|||
|
||||
#include "config.h"
|
||||
|
||||
#include "common/common.h"
|
||||
#include "osdep/io.h"
|
||||
#include "osdep/terminal.h"
|
||||
|
||||
#include "core.h"
|
||||
#include "osdep/main-fn.h"
|
||||
|
||||
int wmain(int argc, wchar_t *argv[]);
|
||||
|
|
@ -0,0 +1 @@
|
|||
int mpv_main(int argc, char *argv[]);
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
}
|
|
@ -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"
|
||||
|
|
|
@ -71,9 +71,12 @@ def build(ctx):
|
|||
source = "demux/ebml.c",
|
||||
target = "ebml_defs.c")
|
||||
|
||||
main_fn_c = {
|
||||
'win32': 'player/main-fn-win.c',
|
||||
}.get(ctx.env.DEST_OS, "player/main-fn-unix.c")
|
||||
if ctx.env.DEST_OS == 'win32':
|
||||
main_fn_c = 'osdep/main-fn-win.c'
|
||||
elif ctx.dependency_satisfied('cocoa'):
|
||||
main_fn_c = 'osdep/main-fn-cocoa.c'
|
||||
else:
|
||||
main_fn_c = 'osdep/main-fn-unix.c'
|
||||
|
||||
getch2_c = {
|
||||
'win32': 'osdep/terminal-win.c',
|
||||
|
|
Loading…
Reference in New Issue