osxvideosink: fix segfault releasing the sink

show_frame is deferred to the main thread and can be called
when the sink has been released, so we need to keep an extra ref
on ObjectiveC object helper.

https://bugzilla.gnome.org/show_bug.cgi?id=708501
This commit is contained in:
Andoni Morales Alastruey 2013-09-20 19:43:21 +02:00 committed by Sebastian Dröge
parent 141a1fc296
commit 05f6c094fa

View file

@ -330,9 +330,11 @@ gst_osx_video_sink_osxwindow_destroy (GstOSXVideoSink * osxvideosink)
g_return_if_fail (GST_IS_OSX_VIDEO_SINK (osxvideosink));
pool = [[NSAutoreleasePool alloc] init];
GST_OBJECT_LOCK (osxvideosink);
gst_osx_video_sink_call_from_main_thread(osxvideosink,
osxvideosink->osxvideosinkobject,
@selector(destroy), (id) nil, YES);
GST_OBJECT_UNLOCK (osxvideosink);
gst_osx_video_sink_stop_cocoa_loop (osxvideosink);
[pool release];
}
@ -779,10 +781,15 @@ gst_osx_video_sink_get_type (void)
-(id) initWithSink: (GstOSXVideoSink*) sink
{
self = [super init];
self->osxvideosink = sink;
self->osxvideosink = gst_object_ref (sink);
return self;
}
-(void) dealloc {
gst_object_unref (osxvideosink);
[super dealloc];
}
-(void) createInternalWindow
{
GstOSXWindow *osxwindow = osxvideosink->osxwindow;
@ -896,6 +903,7 @@ gst_osx_video_sink_get_type (void)
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
GstBuffer *buf = object->buf;
GST_OBJECT_LOCK (osxvideosink);
if (osxvideosink->osxwindow != NULL)
{
gst_buffer_map (buf, &info, GST_MAP_READ);
@ -910,7 +918,7 @@ gst_osx_video_sink_get_type (void)
gst_buffer_unmap (buf, &info);
}
}
GST_OBJECT_UNLOCK (osxvideosink);
[object release];
[pool release];