decodebin3: fix collection refcounting

My collection leak fix 83f30627cd
introduced a crash in this scenario: audiotestsrc ! decodebin3 ! fakesink

The reference handling of collection in decodebin3 wasn't very clear and
my attempt to fix the leak introduced a regression where we went one
reference short in some other scenarios.

Fixing this by:
- Giving a strong reference to DecodebinInput making things clearer
- Fixing get_merged_collection() which was sometimes returning an
  existing reference and sometimes a new one.

https://bugzilla.gnome.org/show_bug.cgi?id=769080
This commit is contained in:
Guillaume Desmottes 2016-07-22 14:35:17 +02:00 committed by Edward Hervey
parent 5044bf79ae
commit 2c0a4d20d4

View file

@ -819,6 +819,8 @@ free_input (GstDecodebin3 * dbin, DecodebinInput * input)
gst_object_unref (input->parsebin);
gst_object_unref (input->parsebin_sink);
}
if (input->collection)
gst_object_unref (input->collection);
g_free (input);
}
@ -1033,7 +1035,7 @@ get_merged_collection (GstDecodebin3 * dbin)
if (!needs_merge) {
GST_DEBUG_OBJECT (dbin, "No need to merge, returning %p", res);
return res;
return gst_object_ref (res);
}
/* We really need to create a new collection */
@ -1142,7 +1144,7 @@ handle_stream_collection (GstDecodebin3 * dbin,
/* Replace collection in input */
if (input->collection)
gst_object_unref (input->collection);
input->collection = collection;
input->collection = gst_object_ref (collection);
GST_DEBUG_OBJECT (dbin, "Setting collection %p on input %p", collection,
input);