applemedia/avsample: Fix racy cleanup of CA layer

The block that is dispatched async to the main thread assumed the
wrapping GstAvSampleVideoSink to be alive. However, at the time of
the block execution the GstObject instance that is deferenced to access
the CA layer might already be freed, which caused occasional crashes.
Instead, we now only pass the CoreAnimation layer that needs to be
released to the block. We use __block to make sure the block is not
increasing the refcount of the CA layer again on its own.

https://bugzilla.gnome.org/show_bug.cgi?id=753081
This commit is contained in:
Heinrich Fink 2015-07-30 23:31:21 +02:00 committed by Matthew Waters
parent 035e51b010
commit 0cc6d16c94

View file

@ -157,10 +157,11 @@ static void
gst_av_sample_video_sink_finalize (GObject * object)
{
GstAVSampleVideoSink *av_sink = GST_AV_SAMPLE_VIDEO_SINK (object);
__block AVSampleBufferDisplayLayer *layer = av_sink->layer;
if (av_sink->layer) {
if (layer) {
dispatch_async (dispatch_get_main_queue (), ^{
[av_sink->layer release];
[layer release];
});
}