v4l2object: mark singleton caps as "may be leaked" objects.

Set MAY_BE_LEAKED flag on static pads returned by gst_v4l2_object_get_*_caps()
functions. Made functions thread safe by using g_once_init[enter|leave]
funtions.

https://bugzilla.gnome.org/show_bug.cgi?id=778453
This commit is contained in:
Juan Pablo Ugarte 2017-02-10 10:32:57 -03:00 committed by Nicolas Dufresne
parent 5c0303708d
commit b6723ecd3c

View file

@ -1577,10 +1577,13 @@ gst_v4l2_object_get_all_caps (void)
{
static GstCaps *caps = NULL;
if (caps == NULL)
caps = gst_v4l2_object_get_caps_helper (GST_V4L2_ALL);
if (g_once_init_enter (&caps)) {
GstCaps *all_caps = gst_v4l2_object_get_caps_helper (GST_V4L2_ALL);
GST_MINI_OBJECT_FLAG_SET (all_caps, GST_MINI_OBJECT_FLAG_MAY_BE_LEAKED);
g_once_init_leave (&caps, all_caps);
}
return gst_caps_ref (caps);
return caps;
}
GstCaps *
@ -1588,10 +1591,13 @@ gst_v4l2_object_get_raw_caps (void)
{
static GstCaps *caps = NULL;
if (caps == NULL)
caps = gst_v4l2_object_get_caps_helper (GST_V4L2_RAW);
if (g_once_init_enter (&caps)) {
GstCaps *raw_caps = gst_v4l2_object_get_caps_helper (GST_V4L2_RAW);
GST_MINI_OBJECT_FLAG_SET (raw_caps, GST_MINI_OBJECT_FLAG_MAY_BE_LEAKED);
g_once_init_leave (&caps, raw_caps);
}
return gst_caps_ref (caps);
return caps;
}
GstCaps *
@ -1599,10 +1605,13 @@ gst_v4l2_object_get_codec_caps (void)
{
static GstCaps *caps = NULL;
if (caps == NULL)
caps = gst_v4l2_object_get_caps_helper (GST_V4L2_CODEC);
if (g_once_init_enter (&caps)) {
GstCaps *codec_caps = gst_v4l2_object_get_caps_helper (GST_V4L2_CODEC);
GST_MINI_OBJECT_FLAG_SET (codec_caps, GST_MINI_OBJECT_FLAG_MAY_BE_LEAKED);
g_once_init_leave (&caps, codec_caps);
}
return gst_caps_ref (caps);
return caps;
}
/* collect data for the given caps