From: Thibault Saunier Date: Mon, 25 Mar 2019 22:11:54 +0000 (-0300) Subject: decodebin: Protect ->source with the object lock X-Git-Tag: 1.19.3~511^2~1137 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9e004b56fe36ec08e77ca3dbb07effac1074e952;p=platform%2Fupstream%2Fgstreamer.git decodebin: Protect ->source with the object lock As expected by the property getter. Basically there are cases where we can be getting the source from any thread and in another thread bring back the element from PAUSED to READY, which leads to a critical warning (or worse). The only place where we use `->source` outside the property getter is the change_state function so the current way of setting/reading it should be safe. --- diff --git a/gst/playback/gsturidecodebin.c b/gst/playback/gsturidecodebin.c index 3d8b137..f19f69a 100644 --- a/gst/playback/gsturidecodebin.c +++ b/gst/playback/gsturidecodebin.c @@ -2076,8 +2076,10 @@ remove_source (GstURIDecodeBin * bin) g_signal_handler_disconnect (source, bin->src_nmp_sig_id); bin->src_nmp_sig_id = 0; } - gst_bin_remove (GST_BIN_CAST (bin), source); + GST_OBJECT_LOCK (bin); bin->source = NULL; + GST_OBJECT_UNLOCK (bin); + gst_bin_remove (GST_BIN_CAST (bin), source); } if (bin->queue) { GST_DEBUG_OBJECT (bin, "removing old queue element"); @@ -2180,6 +2182,7 @@ static gboolean setup_source (GstURIDecodeBin * decoder) { gboolean is_raw, have_out, is_dynamic; + GstElement *source; GST_DEBUG_OBJECT (decoder, "setup source"); @@ -2189,8 +2192,14 @@ setup_source (GstURIDecodeBin * decoder) decoder->pending = 0; /* create and configure an element that can handle the uri */ - if (!(decoder->source = gen_source_element (decoder))) + source = gen_source_element (decoder); + GST_OBJECT_LOCK (decoder); + if (!(decoder->source = source)) { + GST_OBJECT_UNLOCK (decoder); + goto no_source; + } + GST_OBJECT_UNLOCK (decoder); /* state will be merged later - if file is not found, error will be * handled by the application right after. */