summaryrefslogtreecommitdiffstats
path: root/osdep
diff options
context:
space:
mode:
authorStefano Pigozzi <stefano.pigozzi@gmail.com>2013-05-29 21:43:21 +0200
committerStefano Pigozzi <stefano.pigozzi@gmail.com>2013-05-30 23:01:12 +0200
commit1d11db6596cc985050dec3b337e36b0939fa1966 (patch)
tree2226f9e70b09b9737acba5ba2d3ab73fe47d6981 /osdep
parent0057aa476999138c4a5496a4af95a639c01df4d5 (diff)
downloadmpv-1d11db6596cc985050dec3b337e36b0939fa1966.tar.bz2
mpv-1d11db6596cc985050dec3b337e36b0939fa1966.tar.xz
macosx_application: use @autoreleasepool
I don't even want to know how this worked. It scares me a lot.
Diffstat (limited to 'osdep')
-rw-r--r--osdep/macosx_application.h2
-rw-r--r--osdep/macosx_application.m58
2 files changed, 25 insertions, 35 deletions
diff --git a/osdep/macosx_application.h b/osdep/macosx_application.h
index 13a63bc50f..372a57a566 100644
--- a/osdep/macosx_application.h
+++ b/osdep/macosx_application.h
@@ -41,8 +41,6 @@ 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);
diff --git a/osdep/macosx_application.m b/osdep/macosx_application.m
index 6d2d5e03e2..f182a2643d 100644
--- a/osdep/macosx_application.m
+++ b/osdep/macosx_application.m
@@ -28,7 +28,6 @@
#include "video/out/osx_common.h"
static Application *app;
-static NSAutoreleasePool *pool;
static pthread_t playback_thread_id;
@interface Application (PrivateMethods)
@@ -258,31 +257,35 @@ struct playback_thread_ctx {
static void *playback_thread(void *ctx_obj)
{
- struct playback_thread_ctx *ctx = (struct playback_thread_ctx*) ctx_obj;
- ctx->mpv_main(*ctx->argc, *ctx->argv);
- cocoa_stop_runloop();
- pthread_exit(NULL);
+ @autoreleasepool {
+ struct playback_thread_ctx *ctx = (struct playback_thread_ctx*) ctx_obj;
+ ctx->mpv_main(*ctx->argc, *ctx->argv);
+ cocoa_stop_runloop();
+ pthread_exit(NULL);
+ }
}
int cocoa_main(mpv_main_fn mpv_main, int argc, char *argv[])
{
- struct playback_thread_ctx ctx = {0};
- ctx.mpv_main = mpv_main;
- ctx.argc = &argc;
- ctx.argv = &argv;
-
- init_cocoa_application();
- macosx_finder_args_preinit(&argc, &argv);
- pthread_create(&playback_thread_id, NULL, playback_thread, &ctx);
- cocoa_run_runloop();
-
- // This should never be reached: cocoa_run_runloop blocks until the process
- // is quit
- mp_msg(MSGT_CPLAYER, MSGL_ERR, "There was either a problem initializing "
- "Cocoa or the Runloop was stopped unexpectedly. Please report this "
- "issues to a developer.\n");
- pthread_join(playback_thread_id, NULL);
- return 1;
+ @autoreleasepool {
+ struct playback_thread_ctx ctx = {0};
+ ctx.mpv_main = mpv_main;
+ ctx.argc = &argc;
+ ctx.argv = &argv;
+
+ init_cocoa_application();
+ macosx_finder_args_preinit(&argc, &argv);
+ pthread_create(&playback_thread_id, NULL, playback_thread, &ctx);
+ cocoa_run_runloop();
+
+ // This should never be reached: cocoa_run_runloop blocks until the
+ // process is quit
+ mp_msg(MSGT_CPLAYER, MSGL_ERR, "There was either a problem "
+ "initializing Cocoa or the Runloop was stopped unexpectedly. "
+ "Please report this issues to a developer.\n");
+ pthread_join(playback_thread_id, NULL);
+ return 1;
+ }
}
void cocoa_register_menu_item_action(MPMenuKey key, void* action)
@@ -312,17 +315,6 @@ void terminate_cocoa_application(void)
[NSApp terminate:app];
}
-void cocoa_autorelease_pool_alloc(void)
-{
- pool = [[NSAutoreleasePool alloc] init];
-}
-
-void cocoa_autorelease_pool_drain(void)
-{
- [pool drain];
-}
-
-
void cocoa_run_runloop()
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];