mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-23 08:46:40 +00:00
decodebin3: Don't leak collection when releasing inputs
And refactor the function slightly for clarity Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2784>
This commit is contained in:
parent
e276d3c836
commit
b589cf12f2
1 changed files with 60 additions and 54 deletions
|
@ -899,6 +899,9 @@ gst_decodebin3_input_pad_unlink (GstPad * pad, GstObject * parent)
|
||||||
{
|
{
|
||||||
GstDecodebin3 *dbin = (GstDecodebin3 *) parent;
|
GstDecodebin3 *dbin = (GstDecodebin3 *) parent;
|
||||||
DecodebinInput *input = g_object_get_data (G_OBJECT (pad), "decodebin.input");
|
DecodebinInput *input = g_object_get_data (G_OBJECT (pad), "decodebin.input");
|
||||||
|
GstStreamCollection *collection = NULL;
|
||||||
|
gulong probe_id = 0;
|
||||||
|
GstMessage *msg;
|
||||||
|
|
||||||
g_return_if_fail (input);
|
g_return_if_fail (input);
|
||||||
|
|
||||||
|
@ -906,17 +909,12 @@ gst_decodebin3_input_pad_unlink (GstPad * pad, GstObject * parent)
|
||||||
". Removing parsebin.", pad);
|
". Removing parsebin.", pad);
|
||||||
|
|
||||||
INPUT_LOCK (dbin);
|
INPUT_LOCK (dbin);
|
||||||
if (input->parsebin == NULL) {
|
if (input->parsebin == NULL ||
|
||||||
|
GST_OBJECT_PARENT (GST_OBJECT (input->parsebin)) != GST_OBJECT (dbin)) {
|
||||||
INPUT_UNLOCK (dbin);
|
INPUT_UNLOCK (dbin);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GST_OBJECT_PARENT (GST_OBJECT (input->parsebin)) == GST_OBJECT (dbin)) {
|
|
||||||
GstStreamCollection *collection = NULL;
|
|
||||||
gulong probe_id = gst_pad_add_probe (input->parsebin_sink,
|
|
||||||
GST_PAD_PROBE_TYPE_QUERY_UPSTREAM,
|
|
||||||
(GstPadProbeCallback) query_duration_drop_probe, input, NULL);
|
|
||||||
|
|
||||||
/* Clear stream-collection corresponding to current INPUT and post new
|
/* Clear stream-collection corresponding to current INPUT and post new
|
||||||
* stream-collection message, if needed */
|
* stream-collection message, if needed */
|
||||||
if (input->collection) {
|
if (input->collection) {
|
||||||
|
@ -926,8 +924,16 @@ gst_decodebin3_input_pad_unlink (GstPad * pad, GstObject * parent)
|
||||||
|
|
||||||
SELECTION_LOCK (dbin);
|
SELECTION_LOCK (dbin);
|
||||||
collection = get_merged_collection (dbin);
|
collection = get_merged_collection (dbin);
|
||||||
if (collection && collection != dbin->collection) {
|
if (!collection) {
|
||||||
GstMessage *msg;
|
SELECTION_UNLOCK (dbin);
|
||||||
|
goto beach;
|
||||||
|
}
|
||||||
|
if (collection == dbin->collection) {
|
||||||
|
SELECTION_UNLOCK (dbin);
|
||||||
|
gst_object_unref (collection);
|
||||||
|
goto beach;
|
||||||
|
}
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (dbin, "Update Stream Collection");
|
GST_DEBUG_OBJECT (dbin, "Update Stream Collection");
|
||||||
|
|
||||||
if (dbin->collection)
|
if (dbin->collection)
|
||||||
|
@ -936,17 +942,16 @@ gst_decodebin3_input_pad_unlink (GstPad * pad, GstObject * parent)
|
||||||
dbin->select_streams_seqnum = GST_SEQNUM_INVALID;
|
dbin->select_streams_seqnum = GST_SEQNUM_INVALID;
|
||||||
|
|
||||||
msg =
|
msg =
|
||||||
gst_message_new_stream_collection ((GstObject *) dbin,
|
gst_message_new_stream_collection ((GstObject *) dbin, dbin->collection);
|
||||||
dbin->collection);
|
|
||||||
|
/* Drop duration queries that the application might be doing while this message is posted */
|
||||||
|
probe_id = gst_pad_add_probe (input->parsebin_sink,
|
||||||
|
GST_PAD_PROBE_TYPE_QUERY_UPSTREAM,
|
||||||
|
(GstPadProbeCallback) query_duration_drop_probe, input, NULL);
|
||||||
|
|
||||||
SELECTION_UNLOCK (dbin);
|
SELECTION_UNLOCK (dbin);
|
||||||
gst_element_post_message (GST_ELEMENT_CAST (dbin), msg);
|
gst_element_post_message (GST_ELEMENT_CAST (dbin), msg);
|
||||||
update_requested_selection (dbin);
|
update_requested_selection (dbin);
|
||||||
} else {
|
|
||||||
if (collection)
|
|
||||||
gst_object_unref (collection);
|
|
||||||
SELECTION_UNLOCK (dbin);
|
|
||||||
}
|
|
||||||
|
|
||||||
gst_bin_remove (GST_BIN (dbin), input->parsebin);
|
gst_bin_remove (GST_BIN (dbin), input->parsebin);
|
||||||
gst_element_set_state (input->parsebin, GST_STATE_NULL);
|
gst_element_set_state (input->parsebin, GST_STATE_NULL);
|
||||||
|
@ -964,7 +969,8 @@ gst_decodebin3_input_pad_unlink (GstPad * pad, GstObject * parent)
|
||||||
dbin->other_inputs = g_list_remove (dbin->other_inputs, input);
|
dbin->other_inputs = g_list_remove (dbin->other_inputs, input);
|
||||||
free_input_async (dbin, input);
|
free_input_async (dbin, input);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
beach:
|
||||||
INPUT_UNLOCK (dbin);
|
INPUT_UNLOCK (dbin);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue