ges/gstframepositioner: don't create one compositor per frame meta

Instead, cache the looked up operator property

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2623>
This commit is contained in:
Mathieu Duponchelle 2022-06-16 22:40:21 +02:00 committed by GStreamer Marge Bot
parent e1fd0f620f
commit 4b50e674c3

View file

@ -84,6 +84,11 @@ G_DEFINE_TYPE (GstFramePositioner, gst_frame_positioner,
static GType static GType
gst_compositor_operator_get_type_and_default_value (int *default_operator_value) gst_compositor_operator_get_type_and_default_value (int *default_operator_value)
{ {
static gsize _init = 0;
static int operator_value = 0;
static GType operator_gtype = G_TYPE_NONE;
if (g_once_init_enter (&_init)) {
GstElement *compositor = GstElement *compositor =
gst_element_factory_create (ges_get_compositor_factory (), NULL); gst_element_factory_create (ges_get_compositor_factory (), NULL);
@ -93,21 +98,23 @@ gst_compositor_operator_get_type_and_default_value (int *default_operator_value)
GParamSpec *pspec = GParamSpec *pspec =
g_object_class_find_property (G_OBJECT_GET_CLASS (compositorPad), g_object_class_find_property (G_OBJECT_GET_CLASS (compositorPad),
"operator"); "operator");
GType ret = 0;
if (pspec) { if (pspec) {
*default_operator_value = operator_value =
g_value_get_enum (g_param_spec_get_default_value (pspec)); g_value_get_enum (g_param_spec_get_default_value (pspec));
g_return_val_if_fail (pspec, G_TYPE_NONE); operator_gtype = pspec->value_type;
ret = pspec->value_type;
} }
gst_element_release_request_pad (compositor, compositorPad); gst_element_release_request_pad (compositor, compositorPad);
gst_object_unref (compositorPad); gst_object_unref (compositorPad);
gst_object_unref (compositor); gst_object_unref (compositor);
return ret; g_once_init_leave (&_init, 1);
}
*default_operator_value = operator_value;
return operator_gtype;
} }
static void static void