macosx: use automatic -fobjc-arc reference counting

ARC allows automatic reference counting, and thus automatic memory
management, simplifying the whole code.
This commit is contained in:
Alexandre Janniaux 2024-11-18 17:43:38 +01:00 committed by Steve Lhomme
parent d60c7f8fbc
commit 8ef285a45c
2 changed files with 8 additions and 11 deletions

View File

@ -58,6 +58,7 @@ libwindow_macosx_plugin_la_OBJCFLAGS = $(AM_OBJCFLAGS) \
libvout_macosx_plugin_la_SOURCES = video_output/macosx.m \
$(OPENGL_VOUT_COMMONSOURCES)
libvout_macosx_plugin_la_OBJCFLAGS = $(AM_OBJCFLAGS) -fobjc-arc
libvout_macosx_plugin_la_CPPFLAGS = $(AM_CPPFLAGS) -DHAVE_GL_CORE_SYMBOLS -DGL_SILENCE_DEPRECATION
libvout_macosx_plugin_la_LIBADD = libvlc_opengl.la
libvout_macosx_plugin_la_LDFLAGS = $(AM_LDFLAGS) -rpath '$(voutdir)' \

View File

@ -162,12 +162,12 @@ static int Open (vout_display_t *vd,
vd->sys = sys;
/* Get the drawable object */
id container = vd->cfg->window->handle.nsobject;
id container = (__bridge id)vd->cfg->window->handle.nsobject;
assert(container != nil);
/* This will be released in Close(), on
* main thread, after we are done using it. */
sys->container = [container retain];
sys->container = container;
/* Get our main view*/
dispatch_sync(dispatch_get_main_queue(), ^{
@ -276,18 +276,16 @@ static void Close(vout_display_t *vd)
vlc_object_delete(sys->gl);
}
VLCOpenGLVideoView *glView = sys->glView;
id<VLCVideoViewEmbedding> viewContainer = sys->container;
dispatch_async(dispatch_get_main_queue(), ^{
if ([viewContainer respondsToSelector:@selector(removeVoutSubview:)]) {
if ([sys->container respondsToSelector:@selector(removeVoutSubview:)]) {
/* This will retain sys->glView */
[viewContainer removeVoutSubview:sys->glView];
[sys->container removeVoutSubview:sys->glView];
}
/* release on main thread as explained in Open() */
[viewContainer release];
[glView removeFromSuperview];
[glView release];
sys->container = nil;
[sys->glView removeFromSuperview];
sys->glView = nil;
free(sys);
});
}
@ -446,7 +444,6 @@ static void OpenglSwap (vlc_gl_t *gl)
return nil;
self = [super initWithFrame:NSMakeRect(0,0,10,10) pixelFormat:fmt];
[fmt release];
if (!self)
return nil;
@ -484,7 +481,6 @@ static void OpenglSwap (vlc_gl_t *gl)
- (void)dealloc
{
[NSNotificationCenter.defaultCenter removeObserver:self];
[super dealloc];
}
/**