Commit c39e826c authored by Felix Paul Kühne's avatar Felix Paul Kühne

caopengllayer: drop legacy NSAutoreleasePool pattern

parent b8b5a70c
...@@ -114,95 +114,96 @@ static int Open (vlc_object_t *p_this) ...@@ -114,95 +114,96 @@ static int Open (vlc_object_t *p_this)
if (sys == NULL) if (sys == NULL)
return VLC_EGENERIC; return VLC_EGENERIC;
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; @autoreleasepool {
id container = var_CreateGetAddress(vd, "drawable-nsobject");
id container = var_CreateGetAddress(vd, "drawable-nsobject"); if (container)
if (container) vout_display_DeleteWindow(vd, NULL);
vout_display_DeleteWindow(vd, NULL); else {
else { sys->embed = vout_display_NewWindow(vd, VOUT_WINDOW_TYPE_NSOBJECT);
sys->embed = vout_display_NewWindow(vd, VOUT_WINDOW_TYPE_NSOBJECT); if (sys->embed)
if (sys->embed) container = sys->embed->handle.nsobject;
container = sys->embed->handle.nsobject;
if (!container) {
if (!container) { msg_Err(vd, "No drawable-nsobject found!");
msg_Err(vd, "No drawable-nsobject found!"); goto bailout;
goto bailout; }
} }
}
/* store for later, released in Close() */ /* store for later, released in Close() */
sys->container = [container retain]; sys->container = [container retain];
[CATransaction begin];
sys->cgLayer = [[VLCCAOpenGLLayer alloc] init];
[sys->cgLayer setVoutDisplay:vd];
[sys->cgLayer performSelectorOnMainThread:@selector(display)
withObject:nil
waitUntilDone:YES];
if ([container respondsToSelector:@selector(addVoutLayer:)]) {
msg_Dbg(vd, "container implements implicit protocol");
[container addVoutLayer:sys->cgLayer];
} else if ([container respondsToSelector:@selector(addSublayer:)] ||
[container isKindOfClass:[CALayer class]]) {
msg_Dbg(vd, "container doesn't implement implicit protocol, fallback mode used");
[container addSublayer:sys->cgLayer];
} else {
msg_Err(vd, "Provided NSObject container isn't compatible");
[sys->cgLayer release];
sys->cgLayer = nil;
[CATransaction commit];
goto bailout;
}
[CATransaction commit];
[CATransaction begin]; if (!sys->cgLayer)
sys->cgLayer = [[VLCCAOpenGLLayer alloc] init]; goto bailout;
[sys->cgLayer setVoutDisplay:vd];
[sys->cgLayer performSelectorOnMainThread:@selector(display) withObject:nil waitUntilDone:YES]; if (!sys->glContext)
msg_Warn(vd, "we might not have an OpenGL context yet");
/* Initialize common OpenGL video display */
sys->gl.lock = OpenglLock;
sys->gl.unlock = OpenglUnlock;
sys->gl.swap = OpenglSwap;
sys->gl.getProcAddress = OurGetProcAddress;
sys->gl.sys = sys;
const vlc_fourcc_t *subpicture_chromas;
video_format_t fmt = vd->fmt;
sys->vgl = vout_display_opengl_New(&vd->fmt, &subpicture_chromas, &sys->gl);
if (!sys->vgl) {
msg_Err(vd, "Error while initializing opengl display.");
sys->gl.sys = NULL;
goto bailout;
}
if ([container respondsToSelector:@selector(addVoutLayer:)]) { /* setup vout display */
msg_Dbg(vd, "container implements implicit protocol"); vout_display_info_t info = vd->info;
[container addVoutLayer:sys->cgLayer]; info.subpicture_chromas = subpicture_chromas;
} else if ([container respondsToSelector:@selector(addSublayer:)] || [container isKindOfClass:[CALayer class]]) { info.has_hide_mouse = true;
msg_Dbg(vd, "container doesn't implement implicit protocol, fallback mode used"); vd->info = info;
[container addSublayer:sys->cgLayer];
} else { vd->pool = Pool;
msg_Err(vd, "Provided NSObject container isn't compatible"); vd->prepare = PictureRender;
[sys->cgLayer release]; vd->display = PictureDisplay;
sys->cgLayer = nil; vd->control = Control;
[CATransaction commit];
goto bailout; /* setup initial state */
} CGSize outputSize;
[CATransaction commit]; if ([container respondsToSelector:@selector(currentOutputSize)])
outputSize = [container currentOutputSize];
if (!sys->cgLayer) else
goto bailout; outputSize = [sys->container visibleRect].size;
vout_display_SendEventFullscreen(vd, false);
if (!sys->glContext) vout_display_SendEventDisplaySize(vd, (int)outputSize.width, (int)outputSize.height);
msg_Warn(vd, "we might not have an OpenGL context yet");
return VLC_SUCCESS;
/* Initialize common OpenGL video display */
sys->gl.lock = OpenglLock; bailout:
sys->gl.unlock = OpenglUnlock; Close(p_this);
sys->gl.swap = OpenglSwap; return VLC_EGENERIC;
sys->gl.getProcAddress = OurGetProcAddress;
sys->gl.sys = sys;
const vlc_fourcc_t *subpicture_chromas;
video_format_t fmt = vd->fmt;
sys->vgl = vout_display_opengl_New(&vd->fmt, &subpicture_chromas, &sys->gl);
if (!sys->vgl) {
msg_Err(vd, "Error while initializing opengl display.");
sys->gl.sys = NULL;
goto bailout;
} }
/* setup vout display */
vout_display_info_t info = vd->info;
info.subpicture_chromas = subpicture_chromas;
info.has_hide_mouse = true;
vd->info = info;
vd->pool = Pool;
vd->prepare = PictureRender;
vd->display = PictureDisplay;
vd->control = Control;
/* setup initial state */
CGSize outputSize;
if ([container respondsToSelector:@selector(currentOutputSize)])
outputSize = [container currentOutputSize];
else
outputSize = [sys->container visibleRect].size;
vout_display_SendEventFullscreen(vd, false);
vout_display_SendEventDisplaySize(vd, (int)outputSize.width, (int)outputSize.height);
[pool release];
return VLC_SUCCESS;
bailout:
[pool release];
Close(p_this);
return VLC_EGENERIC;
} }
static void Close (vlc_object_t *p_this) static void Close (vlc_object_t *p_this)
......
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