decodebin3: fix dead lock when removing pad

gst_element_remove_pad() is triggering a call to
gst_decodebin3_input_pad_unlink() which needs the input lock as well,
resulting in a dead lock.

Fix #1667

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3614>
This commit is contained in:
Guillaume Desmottes 2022-12-21 10:44:40 +01:00 committed by GStreamer Marge Bot
parent c28bc4492e
commit da696477c6

View file

@ -711,6 +711,7 @@ gst_decodebin3_dispose (GObject * object)
gst_clear_object (&dbin->collection); gst_clear_object (&dbin->collection);
INPUT_LOCK (dbin);
if (dbin->main_input) { if (dbin->main_input) {
free_input (dbin, dbin->main_input); free_input (dbin, dbin->main_input);
dbin->main_input = NULL; dbin->main_input = NULL;
@ -724,6 +725,7 @@ gst_decodebin3_dispose (GObject * object)
free_input (dbin, input); free_input (dbin, input);
dbin->other_inputs = g_list_delete_link (dbin->other_inputs, walk); dbin->other_inputs = g_list_delete_link (dbin->other_inputs, walk);
} }
INPUT_UNLOCK (dbin);
G_OBJECT_CLASS (parent_class)->dispose (object); G_OBJECT_CLASS (parent_class)->dispose (object);
} }
@ -1170,7 +1172,10 @@ free_input (GstDecodebin3 * dbin, DecodebinInput * input)
GST_LOG_OBJECT (dbin, "Freeing input %p", input); GST_LOG_OBJECT (dbin, "Freeing input %p", input);
INPUT_UNLOCK (dbin);
gst_element_remove_pad (GST_ELEMENT (dbin), input->ghost_sink); gst_element_remove_pad (GST_ELEMENT (dbin), input->ghost_sink);
INPUT_LOCK (dbin);
g_free (input); g_free (input);
} }