[vlc-commits] [Git][videolan/vlc][master] 5 commits: caopengllayer: check self and early return
Steve Lhomme (@robUx4)
gitlab at videolan.org
Sat Nov 9 18:10:16 UTC 2024
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
35ab2da6 by Alexandre Janniaux at 2024-11-09T17:15:25+00:00
caopengllayer: check self and early return
The allocator can return a nil object on init, but we can't do anything
and can only do the same then.
- - - - -
5141e7fc by Alexandre Janniaux at 2024-11-09T17:15:25+00:00
opengl: Makefile.am: remove opengl deprecation warning on OSX
- - - - -
bba02261 by Alexandre Janniaux at 2024-11-09T17:15:25+00:00
caopengllayer: use calloc() instead of vlc_obj_calloc()
vlc_obj_calloc() will destroy the sys pointer at the object destruction
but we still need it asynchronously from the main thread on exit
- - - - -
fcbb0108 by Alexandre Janniaux at 2024-11-09T17:15:25+00:00
caopengllayer: enable -fobjc-arc
ARC enables automatic memory reference counting, and is enabled on every
other modules. This is the first step towards moving the existing code
to the same architecture as VLCOpenGLES2VideoView.
- - - - -
1dec8eff by Alexandre Janniaux at 2024-11-09T17:15:25+00:00
caopengllayer: fix leak on error
The context was not saved into the glsys object at this point, so was
never released.
- - - - -
3 changed files:
- modules/video_output/Makefile.am
- modules/video_output/caopengllayer.m
- modules/video_output/opengl/Makefile.am
Changes:
=====================================
modules/video_output/Makefile.am
=====================================
@@ -65,6 +65,7 @@ libvout_macosx_plugin_la_LDFLAGS = $(AM_LDFLAGS) -rpath '$(voutdir)' \
libcaopengllayer_plugin_la_SOURCES = video_output/caopengllayer.m \
$(OPENGL_VOUT_COMMONSOURCES)
+libcaopengllayer_plugin_la_OBJCFLAGS = $(AM_OBJCFLAGS) -fobjc-arc
libcaopengllayer_plugin_la_CPPFLAGS = $(AM_CPPFLAGS) -DHAVE_GL_CORE_SYMBOLS -DGL_SILENCE_DEPRECATION
libcaopengllayer_plugin_la_LIBADD = libvlc_opengl.la
libcaopengllayer_plugin_la_LDFLAGS = $(AM_LDFLAGS) -rpath '$(voutdir)' \
=====================================
modules/video_output/caopengllayer.m
=====================================
@@ -353,10 +353,6 @@ static int Open (vout_display_t *vd,
@autoreleasepool {
vout_display_sys_t *sys;
- vd->sys = sys = vlc_obj_calloc(vd, 1, sizeof(*sys));
- if (sys == NULL)
- return VLC_ENOMEM;
-
// Only use this video output on macOS 10.14 or higher
// currently, as it has some issues on at least macOS 10.7
// and the old NSView based output still works fine on old
@@ -364,25 +360,30 @@ static int Open (vout_display_t *vd,
if (@available(macOS 10.14, *)) {
// This is intentionally left empty, as the check
// can not be negated or combined with other conditions!
- } else {
- if (!vd->obj.force)
- return VLC_EGENERIC;
+ } else if (!vd->obj.force) {
+ return VLC_EGENERIC;
}
- id container = vd->cfg->window->handle.nsobject;
+ vd->sys = sys = calloc(1, sizeof(*sys));
+ if (sys == NULL)
+ return VLC_ENOMEM;
+
+ id container = (__bridge id)vd->cfg->window->handle.nsobject;
if (!container) {
msg_Err(vd, "No drawable-nsobject found!");
- goto error;
+ Close(vd);
+ return VLC_EGENERIC;
}
// Retain container, released in Close
- sys->container = [container retain];
+ sys->container = container;
// Create the CGL context
CGLContextObj cgl_ctx = vlc_CreateCGLContext();
if (cgl_ctx == NULL) {
msg_Err(vd, "Failure to create CGL context!");
- goto error;
+ Close(vd);
+ return VLC_EGENERIC;
}
// Create a pseudo-context object which provides needed callbacks
@@ -390,7 +391,12 @@ static int Open (vout_display_t *vd,
// by a proper opengl provider module, but we do not have that currently.
sys->gl = vlc_object_create(vd, sizeof(*sys->gl));
if (unlikely(!sys->gl))
- goto error;
+ {
+ CGLReleaseContext(cgl_ctx);
+ Close(vd);
+ return VLC_ENOMEM;
+ }
+
static const struct vlc_gl_operations gl_ops =
{
@@ -415,7 +421,7 @@ static int Open (vout_display_t *vd,
// Create video view
sys->videoView = [[VLCVideoLayerView alloc] initWithVoutDisplay:vd];
- sys->videoLayer = (VLCCAOpenGLLayer*)[[sys->videoView layer] retain];
+ sys->videoLayer = (VLCCAOpenGLLayer*)[sys->videoView layer];
// Add video view to container
if ([container respondsToSelector:@selector(addVoutSubview:)]) {
[container addVoutSubview:sys->videoView];
@@ -424,8 +430,6 @@ static int Open (vout_display_t *vd,
[containerView addSubview:sys->videoView];
[sys->videoView setFrame:containerView.bounds];
} else {
- [sys->videoView release];
- [sys->videoLayer release];
sys->videoView = nil;
sys->videoLayer = nil;
}
@@ -439,7 +443,8 @@ static int Open (vout_display_t *vd,
msg_Err(vd,
"Invalid drawable-nsobject object, must either be an NSView "
"or comply with the VLCOpenGLVideoViewEmbedding protocol");
- goto error;
+ Close(vd);
+ return VLC_EGENERIC;
}
@@ -447,7 +452,10 @@ static int Open (vout_display_t *vd,
const vlc_fourcc_t *spu_chromas;
if (vlc_gl_MakeCurrent(sys->gl))
- goto error;
+ {
+ Close(vd);
+ return VLC_EGENERIC;
+ }
sys->vgl = vout_display_opengl_New(fmt, &spu_chromas, sys->gl,
&vd->cfg->viewpoint, context);
@@ -455,7 +463,8 @@ static int Open (vout_display_t *vd,
if (sys->vgl == NULL) {
msg_Err(vd, "Error while initializing OpenGL display");
- goto error;
+ Close(vd);
+ return VLC_EGENERIC;
}
vd->info.subpicture_chromas = spu_chromas;
@@ -464,10 +473,6 @@ static int Open (vout_display_t *vd,
atomic_init(&sys->is_ready, false);
return VLC_SUCCESS;
-
- error:
- Close(vd);
- return VLC_EGENERIC;
}
}
@@ -498,22 +503,17 @@ static void Close(vout_display_t *vd)
free(glsys);
}
- // Copy pointers out of sys, as sys can be gone already
- // when the dispatch_async block is run!
- id container = sys->container;
- VLCVideoLayerView *videoView = sys->videoView;
- VLCCAOpenGLLayer *videoLayer = sys->videoLayer;
-
dispatch_async(dispatch_get_main_queue(), ^{
// Remove vout subview from container
- if ([container respondsToSelector:@selector(removeVoutSubview:)]) {
- [container removeVoutSubview:videoView];
+ if ([sys->container respondsToSelector:@selector(removeVoutSubview:)]) {
+ [sys->container removeVoutSubview:sys->videoView];
}
- [videoView removeFromSuperview];
+ [sys->videoView removeFromSuperview];
- [videoView release];
- [container release];
- [videoLayer release];
+ sys->videoView = nil;
+ sys->container = nil;
+ sys->videoLayer = nil;
+ free(sys);
});
}
@@ -595,12 +595,12 @@ static int Control (vout_display_t *vd, int query)
- (instancetype)initWithVoutDisplay:(vout_display_t *)vd
{
self = [super init];
- if (self) {
- _vlc_vd = vd;
+ if (self == nil)
+ return nil;
+ _vlc_vd = vd;
- self.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable;
- self.wantsLayer = YES;
- }
+ self.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable;
+ self.wantsLayer = YES;
return self;
}
@@ -638,7 +638,7 @@ static int Control (vout_display_t *vd, int query)
VLCCAOpenGLLayer *layer = [[VLCCAOpenGLLayer alloc] initWithVoutDisplay:_vlc_vd];
layer.delegate = self;
- return [layer autorelease];
+ return layer;
}
}
@@ -706,8 +706,6 @@ shouldInheritContentsScale:(CGFloat)newScale
- (void)dealloc
{
CGLReleaseContext(_glContext);
- [_displayLock release];
- [super dealloc];
}
- (void)display
=====================================
modules/video_output/opengl/Makefile.am
=====================================
@@ -37,6 +37,7 @@ OPENGL_VOUT_COMMONSOURCES = \
# Convenience library for OpenGL components -- OpenGL only
libvlc_opengl_la_SOURCES = $(OPENGL_COMMONSOURCES)
libvlc_opengl_la_CFLAGS = $(OPENGL_COMMONCFLAGS)
+libvlc_opengl_la_CPPFLAGS =
libvlc_opengl_la_LIBADD = $(OPENGL_COMMONLIBS) $(LIBM)
libvlc_opengl_la_LDFLAGS = -static -no-undefined
@@ -97,6 +98,7 @@ endif
libgl_plugin_la_SOURCES = video_output/opengl/display.c \
$(OPENGL_VOUT_COMMONSOURCES)
libgl_plugin_la_CFLAGS = $(AM_CFLAGS) $(GL_CFLAGS) $(OPENGL_COMMONCFLAGS)
+libgl_plugin_la_CPPFLAGS = $(AM_CPPFLAGS)
libgl_plugin_la_LIBADD = libvlc_opengl.la
if HAVE_GL
vout_LTLIBRARIES += libgl_plugin.la
@@ -104,6 +106,8 @@ endif # HAVE_GL
if HAVE_OSX
vout_LTLIBRARIES += libgl_plugin.la
+libvlc_opengl_la_CPPFLAGS += -DGL_SILENCE_DEPRECATION
+libgl_plugin_la_CPPFLAGS += -DGL_SILENCE_DEPRECATION
endif
libglfilter_draw_plugin_la_SOURCES = video_output/opengl/filter_draw.c
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/7e269398132d1e2d8382e3b86ea322a13146ca79...1dec8eff9011490f26071d89e1a0bced8d507261
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/7e269398132d1e2d8382e3b86ea322a13146ca79...1dec8eff9011490f26071d89e1a0bced8d507261
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list