Commit 91721c03 authored by Felix Paul Kühne's avatar Felix Paul Kühne

vout macosx: drop legacy NSAutoreleasePool pattern

parent c39e826c
......@@ -138,11 +138,11 @@ static int Open (vlc_object_t *this)
{
vout_display_t *vd = (vout_display_t *)this;
vout_display_sys_t *sys = calloc (1, sizeof(*sys));
NSAutoreleasePool *nsPool = nil;
if (!sys)
return VLC_ENOMEM;
@autoreleasepool {
if (!CGDisplayUsesOpenGLAcceleration (kCGDirectMainDisplay))
msg_Err (this, "no OpenGL hardware acceleration found. this can lead to slow output and unexpected results");
......@@ -171,9 +171,9 @@ static int Open (vlc_object_t *this)
sys->container = [container retain];
/* Get our main view*/
nsPool = [[NSAutoreleasePool alloc] init];
[VLCOpenGLVideoView performSelectorOnMainThread:@selector(getNewView:) withObject:[NSValue valueWithPointer:&sys->glView] waitUntilDone:YES];
[VLCOpenGLVideoView performSelectorOnMainThread:@selector(getNewView:)
withObject:[NSValue valueWithPointer:&sys->glView]
waitUntilDone:YES];
if (!sys->glView) {
msg_Err(vd, "Initialization of open gl view failed");
goto error;
......@@ -185,20 +185,22 @@ static int Open (vlc_object_t *this)
* container.
* That's why we'll release on main thread in Close(). */
if ([(id)container respondsToSelector:@selector(addVoutSubview:)])
[(id)container performSelectorOnMainThread:@selector(addVoutSubview:) withObject:sys->glView waitUntilDone:NO];
[(id)container performSelectorOnMainThread:@selector(addVoutSubview:)
withObject:sys->glView
waitUntilDone:NO];
else if ([container isKindOfClass:[NSView class]]) {
NSView *parentView = container;
[parentView performSelectorOnMainThread:@selector(addSubview:) withObject:sys->glView waitUntilDone:NO];
[sys->glView performSelectorOnMainThread:@selector(setFrameToBoundsOfView:) withObject:[NSValue valueWithPointer:parentView] waitUntilDone:NO];
[parentView performSelectorOnMainThread:@selector(addSubview:)
withObject:sys->glView
waitUntilDone:NO];
[sys->glView performSelectorOnMainThread:@selector(setFrameToBoundsOfView:)
withObject:[NSValue valueWithPointer:parentView]
waitUntilDone:NO];
} else {
msg_Err(vd, "Invalid drawable-nsobject object. drawable-nsobject must either be an NSView or comply to the @protocol VLCOpenGLVideoViewEmbedding.");
goto error;
}
[nsPool release];
nsPool = nil;
/* Initialize common OpenGL video display */
sys->gl.lock = OpenglLock;
sys->gl.unlock = OpenglUnlock;
......@@ -234,10 +236,10 @@ static int Open (vlc_object_t *this)
return VLC_SUCCESS;
error:
[nsPool release];
error:
Close(this);
return VLC_EGENERIC;
}
}
void Close (vlc_object_t *this)
......@@ -245,16 +247,23 @@ void Close (vlc_object_t *this)
vout_display_t *vd = (vout_display_t *)this;
vout_display_sys_t *sys = vd->sys;
@autoreleasepool {
[sys->glView setVoutDisplay:nil];
var_Destroy (vd, "drawable-nsobject");
if ([(id)sys->container respondsToSelector:@selector(removeVoutSubview:)])
/* This will retain sys->glView */
[(id)sys->container performSelectorOnMainThread:@selector(removeVoutSubview:) withObject:sys->glView waitUntilDone:NO];
[(id)sys->container performSelectorOnMainThread:@selector(removeVoutSubview:)
withObject:sys->glView
waitUntilDone:NO];
/* release on main thread as explained in Open() */
[(id)sys->container performSelectorOnMainThread:@selector(release) withObject:nil waitUntilDone:NO];
[sys->glView performSelectorOnMainThread:@selector(removeFromSuperview) withObject:nil waitUntilDone:NO];
[(id)sys->container performSelectorOnMainThread:@selector(release)
withObject:nil
waitUntilDone:NO];
[sys->glView performSelectorOnMainThread:@selector(removeFromSuperview)
withObject:nil
waitUntilDone:NO];
if (sys->gl.sys != NULL)
vout_display_opengl_Delete (sys->vgl);
......@@ -264,6 +273,7 @@ void Close (vlc_object_t *this)
if (sys->embed)
vout_display_DeleteWindow (vd, sys->embed);
free (sys);
}
}
/*****************************************************************************
......@@ -311,6 +321,7 @@ static int Control (vout_display_t *vd, int query, va_list ap)
if (!sys->embed)
return VLC_EGENERIC;
@autoreleasepool {
switch (query)
{
case VOUT_DISPLAY_CHANGE_DISPLAY_FILLED:
......@@ -319,11 +330,9 @@ static int Control (vout_display_t *vd, int query, va_list ap)
case VOUT_DISPLAY_CHANGE_SOURCE_CROP:
case VOUT_DISPLAY_CHANGE_DISPLAY_SIZE:
{
NSAutoreleasePool * o_pool = [[NSAutoreleasePool alloc] init];
id o_window = [sys->glView window];
if (!o_window) {
[o_pool release];
return VLC_SUCCESS; // this is okay, since the event will occur again when we have a window
}
......@@ -364,8 +373,6 @@ static int Control (vout_display_t *vd, int query, va_list ap)
// x / y are top left corner, but we need the lower left one
glViewport (place.x, cfg_tmp.display.height - (place.y + place.height), place.width, place.height);
[o_pool release];
return VLC_SUCCESS;
}
......@@ -381,6 +388,7 @@ static int Control (vout_display_t *vd, int query, va_list ap)
msg_Err (vd, "Unknown request in Mac OS X vout display");
return VLC_EGENERIC;
}
}
}
/*****************************************************************************
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment