path: root/osdep/macosx_application.h
diff options
authorStefano Pigozzi <>2013-03-04 14:23:06 +0100
committerStefano Pigozzi <>2013-05-12 15:27:54 +0200
commit134f3e97bf482b75c0eccbe5ac943a2a1d5a4ad6 (patch)
tree98bac431df2697072238864e48a0380d3b1745ff /osdep/macosx_application.h
parentafdc9c4ae2e69a9ced6c3c6580df19edfedea36a (diff)
OSX: run native event loop in a separate thread
This commit is a followup on the previous one and uses a solution I like more since it totally decouples the Cocoa code from mpv's core and tries to emulate a generic Cocoa application's lifecycle as much as possible without fighting the framework. mpv's main is executed in a pthread while the main thread runs the native cocoa event loop. All of the thread safety is mainly accomplished with additional logic in cocoa_common as to not increase complexity on the crossplatform parts of the code.
Diffstat (limited to 'osdep/macosx_application.h')
1 files changed, 8 insertions, 9 deletions
diff --git a/osdep/macosx_application.h b/osdep/macosx_application.h
index c2227ae05d..b0f7944512 100644
--- a/osdep/macosx_application.h
+++ b/osdep/macosx_application.h
@@ -22,9 +22,7 @@
struct input_ctx;
struct mp_fifo;
-// Playloop callback function pointer
-typedef void(*play_loop_callback)(void *);
-typedef int(*should_stop_callback)(void *);
+typedef int (*mpv_main_fn)(int, char**);
// Menu Keys identifing menu items
typedef enum {
@@ -35,22 +33,23 @@ typedef enum {
} MPMenuKey;
+// multithreaded wrapper for mpv_main
+int cocoa_main(mpv_main_fn mpv_main, int argc, char *argv[]);
void cocoa_register_menu_item_action(MPMenuKey key, void* action);
// initializes Cocoa application
void init_cocoa_application(void);
void terminate_cocoa_application(void);
+void cocoa_autorelease_pool_alloc(void);
+void cocoa_autorelease_pool_drain(void);
// Runs the Cocoa Main Event Loop
void cocoa_run_runloop(void);
+void cocoa_stop_runloop(void);
void cocoa_post_fake_event(void);
-// Adds play_loop as a timer of the Main Cocoa Event Loop
-void cocoa_run_loop_schedule(play_loop_callback callback,
- should_stop_callback playback_stopped,
- void *context,
- struct input_ctx *input_context,
- struct mp_fifo *key_fifo);
+void cocoa_set_state(struct input_ctx *input_context, struct mp_fifo *key_fifo);
void macosx_finder_args_preinit(int *argc, char ***argv);