libs: display: initialize value if they are not yet
authorVíctor Manuel Jáquez Leal <vjaquez@igalia.com>
Fri, 22 Sep 2017 16:59:49 +0000 (18:59 +0200)
committerVíctor Manuel Jáquez Leal <vjaquez@igalia.com>
Fri, 22 Sep 2017 18:06:42 +0000 (20:06 +0200)
This is a difference between the GObject API and the GstVaapi one: the
GValue passed to get a property value, in GObject has to be
initialized with g_value_init(), but in GstVaapi is has not.

In order to overcome this mismatch, this patch call g_value_init()
internally only in the passed one is not already initialized.

https://bugzilla.gnome.org/show_bug.cgi?id=788058

gst-libs/gst/vaapi/gstvaapidisplay.c

index de31e01..1d34434 100644 (file)
@@ -1002,14 +1002,16 @@ _get_property (GstVaapiDisplay * display, const GstVaapiProperty * prop,
       GstVaapiRenderMode mode;
       if (!gst_vaapi_display_get_render_mode (display, &mode))
         return FALSE;
-      g_value_init (value, GST_VAAPI_TYPE_RENDER_MODE);
+      if (!G_IS_VALUE (value))
+        g_value_init (value, GST_VAAPI_TYPE_RENDER_MODE);
       g_value_set_enum (value, mode);
       break;
     }
     case VADisplayAttribRotation:{
       GstVaapiRotation rotation;
       rotation = gst_vaapi_display_get_rotation (display);
-      g_value_init (value, GST_VAAPI_TYPE_ROTATION);
+      if (!G_IS_VALUE (value))
+        g_value_init (value, GST_VAAPI_TYPE_ROTATION);
       g_value_set_enum (value, rotation);
       break;
     }
@@ -1020,7 +1022,8 @@ _get_property (GstVaapiDisplay * display, const GstVaapiProperty * prop,
       gfloat val;
       if (!get_color_balance (display, find_property_id (prop->name), &val))
         return FALSE;
-      g_value_init (value, G_TYPE_FLOAT);
+      if (!G_IS_VALUE (value))
+        g_value_init (value, G_TYPE_FLOAT);
       g_value_set_float (value, val);
       break;
     }