[Bug 693800] New: Problem with ref counter in adding/removing element to/from bin more than once
GStreamer (bugzilla.gnome.org)
bugzilla at gnome.org
Thu Feb 14 06:41:37 PST 2013
https://bugzilla.gnome.org/show_bug.cgi?id=693800
GStreamer | gstreamer (core) | 1.x
Summary: Problem with ref counter in adding/removing element
to/from bin more than once
Classification: Platform
Product: GStreamer
Version: 1.x
OS/Version: Linux
Status: UNCONFIRMED
Severity: normal
Priority: Normal
Component: gstreamer (core)
AssignedTo: gstreamer-bugs at lists.freedesktop.org
ReportedBy: alexas at axis.com
QAContact: gstreamer-bugs at lists.freedesktop.org
GNOME version: ---
This case:
GstElement *element = gst_element_factory_make("fakesink", NULL);
GstBin *bin = (GstBin*)gst_bin_new("test");
g_print("refcount: %u\n", GST_OBJECT_REFCOUNT(element));
gst_bin_add(bin, gst_object_ref(element));
g_print("refcount: %u\n", GST_OBJECT_REFCOUNT(element));
gst_bin_remove(bin, element);
g_print("refcount: %u\n", GST_OBJECT_REFCOUNT(element));
gst_bin_add(bin, gst_object_ref(element));
g_print("refcount: %u\n", GST_OBJECT_REFCOUNT(element));
gst_bin_remove(bin, element);
Should result in the refcount being 'stable' since gst_bin_add has a full
transfer and to keep the ref outside you need to ref once more. This is not the
case however, the ref increases. The scary part is that it does not increase
the first time. The reason is that part of the operation is
gst_object_set_parent, which takes the floating reference. The first time we do
this the element is indeed floating and the ref count is not changed, the rest
of the time it will increase the ref by one.
If we do indeed want the floating ref to behave as it does then we need to
unref when setting parent to NULL in bin_remove (we just set the variable to
NULL right now). This will however cause the ref count to drop to zero since we
'steal' a reference count from the outside when doing that (the floating one).
I will take a look at a possible solution tomorrow.
--
Configure bugmail: https://bugzilla.gnome.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.
More information about the gstreamer-bugs
mailing list