[vlc-commits] minimal-macosx: switch to ARC

Felix Paul Kühne git at videolan.org
Tue Jul 21 12:20:28 CEST 2015


vlc | branch: master | Felix Paul Kühne <fkuehne at videolan.org> | Tue Jul 21 12:19:52 2015 +0200| [6916c8d1365204b7cbd78768c2c048e9781ec224] | committer: Felix Paul Kühne

minimal-macosx: switch to ARC

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=6916c8d1365204b7cbd78768c2c048e9781ec224
---

 modules/gui/Makefile.am           |    2 +-
 modules/gui/minimal_macosx/intf.m |   93 +++++++++++++++++--------------------
 2 files changed, 43 insertions(+), 52 deletions(-)

diff --git a/modules/gui/Makefile.am b/modules/gui/Makefile.am
index 47bd638..a5f4f65 100644
--- a/modules/gui/Makefile.am
+++ b/modules/gui/Makefile.am
@@ -39,7 +39,7 @@ libminimal_macosx_plugin_la_SOURCES = \
 	gui/minimal_macosx/misc.h gui/minimal_macosx/misc.m \
 	gui/minimal_macosx/VLCMinimalVoutWindow.h gui/minimal_macosx/VLCMinimalVoutWindow.m \
 	gui/minimal_macosx/macosx.c
-libminimal_macosx_plugin_la_OBJCFLAGS = $(AM_OBJCFLAGS) -fobjc-exceptions
+libminimal_macosx_plugin_la_OBJCFLAGS = $(AM_OBJCFLAGS) -fobjc-arc -fobjc-exceptions
 libminimal_macosx_plugin_la_LDFLAGS = $(AM_LDFLAGS) -rpath '$(guidir)' -Wl,-framework,Cocoa
 EXTRA_LTLIBRARIES += libminimal_macosx_plugin.la
 gui_LTLIBRARIES += $(LTLIBminimal_macosx)
diff --git a/modules/gui/minimal_macosx/intf.m b/modules/gui/minimal_macosx/intf.m
index 7c69e4e..b803a9f 100644
--- a/modules/gui/minimal_macosx/intf.m
+++ b/modules/gui/minimal_macosx/intf.m
@@ -92,14 +92,13 @@ extern OSErr    CPSSetFrontProcess(CPSProcessSerNum *psn);
 static void Run(intf_thread_t *p_intf)
 {
     CPSProcessSerNum PSN;
-    NSAutoreleasePool   *pool = [[NSAutoreleasePool alloc] init];
-    [NSApplication sharedApplication];
-    if (!CPSGetCurrentProcess(&PSN))
-        if (!CPSEnableForegroundOperation(&PSN,0x03,0x3C,0x2C,0x1103))
-            if (!CPSSetFrontProcess(&PSN))
-                [NSApplication sharedApplication];
-
-    [pool release];
+    @autoreleasepool {
+        [NSApplication sharedApplication];
+        if (!CPSGetCurrentProcess(&PSN))
+            if (!CPSEnableForegroundOperation(&PSN,0x03,0x3C,0x2C,0x1103))
+                if (!CPSSetFrontProcess(&PSN))
+                    [NSApplication sharedApplication];
+    }
 }
 
 /*****************************************************************************
@@ -113,32 +112,30 @@ int WindowOpen(vout_window_t *p_wnd, const vout_window_cfg_t *cfg)
      && cfg->type != VOUT_WINDOW_TYPE_NSOBJECT)
         return VLC_EGENERIC;
 
-    NSAutoreleasePool *o_pool = [[NSAutoreleasePool alloc] init];
-
-    NSRect proposedVideoViewPosition = NSMakeRect(cfg->x, cfg->y, cfg->width, cfg->height);
+    @autoreleasepool {
+        NSRect proposedVideoViewPosition = NSMakeRect(cfg->x, cfg->y, cfg->width, cfg->height);
 
-    VLCMinimalVoutWindow *o_window = [[VLCMinimalVoutWindow alloc] initWithContentRect:proposedVideoViewPosition];
-    [o_window makeKeyAndOrderFront:nil];
+        VLCMinimalVoutWindow *o_window = [[VLCMinimalVoutWindow alloc] initWithContentRect:proposedVideoViewPosition];
+        [o_window makeKeyAndOrderFront:nil];
 
-    if (!o_window) {
-        msg_Err(p_wnd, "window creation failed");
-        [o_pool release];
-        return VLC_EGENERIC;
-    }
+        if (!o_window) {
+            msg_Err(p_wnd, "window creation failed");
+            return VLC_EGENERIC;
+        }
 
-    msg_Dbg(p_wnd, "returning video window with proposed position x=%i, y=%i, width=%i, height=%i", cfg->x, cfg->y, cfg->width, cfg->height);
-    p_wnd->handle.nsobject = [o_window contentView];
+        msg_Dbg(p_wnd, "returning video window with proposed position x=%i, y=%i, width=%i, height=%i", cfg->x, cfg->y, cfg->width, cfg->height);
+        p_wnd->handle.nsobject = (void *)CFBridgingRetain([o_window contentView]);
 
-    p_wnd->type = VOUT_WINDOW_TYPE_NSOBJECT;
-    p_wnd->control = WindowControl;
+        p_wnd->type = VOUT_WINDOW_TYPE_NSOBJECT;
+        p_wnd->control = WindowControl;
+    }
 
-    [o_pool release];
     return VLC_SUCCESS;
 }
 
 static int WindowControl(vout_window_t *p_wnd, int i_query, va_list args)
 {
-    NSWindow * o_window = [(id)p_wnd->handle.nsobject window];
+    NSWindow * o_window = [(__bridge id)p_wnd->handle.nsobject window];
     if (!o_window) {
         msg_Err(p_wnd, "failed to recover cocoa window");
         return VLC_EGENERIC;
@@ -155,29 +152,26 @@ static int WindowControl(vout_window_t *p_wnd, int i_query, va_list args)
         }
         case VOUT_WINDOW_SET_SIZE:
         {
-            NSAutoreleasePool *o_pool = [[NSAutoreleasePool alloc] init];
-
-            NSRect theFrame = [o_window frame];
-            unsigned int i_width  = va_arg(args, unsigned int);
-            unsigned int i_height = va_arg(args, unsigned int);
-            theFrame.size.width = i_width;
-            theFrame.size.height = i_height;
-            [o_window setFrame: theFrame display: YES animate: YES];
-
-            [o_pool release];
+            @autoreleasepool {
+                NSRect theFrame = [o_window frame];
+                unsigned int i_width  = va_arg(args, unsigned int);
+                unsigned int i_height = va_arg(args, unsigned int);
+                theFrame.size.width = i_width;
+                theFrame.size.height = i_height;
+                [o_window setFrame: theFrame display: YES animate: YES];
+            }
             return VLC_SUCCESS;
         }
         case VOUT_WINDOW_SET_FULLSCREEN:
         {
-            NSAutoreleasePool *o_pool = [[NSAutoreleasePool alloc] init];
-            int i_full = va_arg(args, int);
-
-            if (i_full)
-                [o_window performSelectorOnMainThread:@selector(enterFullscreen) withObject:nil waitUntilDone:NO];
-            else
-                [o_window performSelectorOnMainThread:@selector(leaveFullscreen) withObject:nil waitUntilDone:NO];
-
-            [o_pool release];
+            @autoreleasepool {
+                int i_full = va_arg(args, int);
+
+                if (i_full)
+                    [o_window performSelectorOnMainThread:@selector(enterFullscreen) withObject:nil waitUntilDone:NO];
+                else
+                    [o_window performSelectorOnMainThread:@selector(leaveFullscreen) withObject:nil waitUntilDone:NO];
+            }
             return VLC_SUCCESS;
         }
         default:
@@ -188,12 +182,9 @@ static int WindowControl(vout_window_t *p_wnd, int i_query, va_list args)
 
 void WindowClose(vout_window_t *p_wnd)
 {
-    NSAutoreleasePool *o_pool = [[NSAutoreleasePool alloc] init];
-
-    NSWindow * o_window = [(id)p_wnd->handle.nsobject window];
-    if (o_window)
-        [o_window release];
-
-    [o_pool release];
+    @autoreleasepool {
+        NSWindow * o_window = [(__bridge id)p_wnd->handle.nsobject window];
+        if (o_window)
+            o_window = nil;
+    }
 }
-



More information about the vlc-commits mailing list