gl: Add/fix various annotations
authorSebastian Dröge <sebastian@centricular.com>
Sat, 15 Oct 2022 09:16:01 +0000 (12:16 +0300)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Tue, 18 Oct 2022 08:56:58 +0000 (08:56 +0000)
And fix a memory leaks in gst_gl_display_egl_new() error cases.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3194>

17 files changed:
subprojects/gst-plugins-base/gst-libs/gst/gl/cocoa/gstgldisplay_cocoa.m
subprojects/gst-plugins-base/gst-libs/gst/gl/egl/gsteglimage.c
subprojects/gst-plugins-base/gst-libs/gst/gl/egl/gstgldisplay_egl.c
subprojects/gst-plugins-base/gst-libs/gst/gl/egl/gstgldisplay_egl_device.c
subprojects/gst-plugins-base/gst-libs/gst/gl/gstglbasememory.c
subprojects/gst-plugins-base/gst-libs/gst/gl/gstglbasememory.h
subprojects/gst-plugins-base/gst-libs/gst/gl/gstglbufferpool.c
subprojects/gst-plugins-base/gst-libs/gst/gl/gstglcolorconvert.c
subprojects/gst-plugins-base/gst-libs/gst/gl/gstglcontext.c
subprojects/gst-plugins-base/gst-libs/gst/gl/gstgldisplay.c
subprojects/gst-plugins-base/gst-libs/gst/gl/gstglformat.c
subprojects/gst-plugins-base/gst-libs/gst/gl/gstglshader.c
subprojects/gst-plugins-base/gst-libs/gst/gl/gstglsl.c
subprojects/gst-plugins-base/gst-libs/gst/gl/gstglviewconvert.c
subprojects/gst-plugins-base/gst-libs/gst/gl/viv-fb/gstgldisplay_viv_fb.c
subprojects/gst-plugins-base/gst-libs/gst/gl/wayland/gstgldisplay_wayland.c
subprojects/gst-plugins-base/gst-libs/gst/gl/x11/gstgldisplay_x11.c

index 01126eb..cf9ad2b 100644 (file)
@@ -228,7 +228,7 @@ gst_gl_display_cocoa_finalize (GObject * object)
  *
  * Create a new #GstGLDisplayCocoa.
  *
- * Returns: (transfer full): a new #GstGLDisplayCocoa or %NULL
+ * Returns: (transfer full): a new #GstGLDisplayCocoa
  */
 GstGLDisplayCocoa *
 gst_gl_display_cocoa_new (void)
index 756ecc0..f97d85b 100644 (file)
@@ -452,7 +452,7 @@ _destroy_egl_image (GstEGLImage * image, gpointer user_data)
  * @gl_mem: a #GstGLMemory
  * @attribs: additional attributes to add to the `eglCreateImage`() call.
  *
- * Returns: (transfer full): a #GstEGLImage wrapping @gl_mem or %NULL on failure
+ * Returns: (transfer full) (nullable): a #GstEGLImage wrapping @gl_mem or %NULL on failure
  */
 GstEGLImage *
 gst_egl_image_from_texture (GstGLContext * context, GstGLMemory * gl_mem,
@@ -641,7 +641,7 @@ get_egl_stride (const GstVideoInfo * info, gint plane)
  * With NV12, two EGL images are created, one with R format, one
  * with RG format etc.
  *
- * Returns: a #GstEGLImage wrapping @dmabuf or %NULL on failure
+ * Returns: (nullable): a #GstEGLImage wrapping @dmabuf or %NULL on failure
  */
 GstEGLImage *
 gst_egl_image_from_dmabuf (GstGLContext * context,
@@ -927,7 +927,7 @@ gst_egl_image_check_dmabuf_direct (GstGLContext * context,
  * is that this function creates one EGL image for all planes, not one for
  * a single plane.
  *
- * Returns: a #GstEGLImage wrapping @dmabuf or %NULL on failure
+ * Returns: (nullable): a #GstEGLImage wrapping @dmabuf or %NULL on failure
  *
  * Since: 1.18
  */
@@ -1094,7 +1094,7 @@ gst_egl_image_from_dmabuf_direct_target (GstGLContext * context,
  * is that this function creates one EGL image for all planes, not one for
  * a single plane.
  *
- * Returns: a #GstEGLImage wrapping @dmabuf or %NULL on failure
+ * Returns: (nullable): a #GstEGLImage wrapping @dmabuf or %NULL on failure
  */
 GstEGLImage *
 gst_egl_image_from_dmabuf_direct (GstGLContext * context,
index 6562d8d..e617b8a 100644 (file)
@@ -125,7 +125,7 @@ gst_gl_display_egl_finalize (GObject * object)
  * %GST_GL_DISPLAY_TYPE_ANY, then @display must be 0. @type must not be
  * %GST_GL_DISPLAY_TYPE_NONE.
  *
- * Returns: A `EGLDisplay` or `EGL_NO_DISPLAY`
+ * Returns: (nullable): A `EGLDisplay` or `EGL_NO_DISPLAY`
  *
  * Since: 1.12
  */
@@ -248,24 +248,27 @@ default_display:
  *
  * Create a new #GstGLDisplayEGL using the default EGL_DEFAULT_DISPLAY.
  *
- * Returns: (transfer full): a new #GstGLDisplayEGL or %NULL
+ * Returns: (transfer full) (nullable): a new #GstGLDisplayEGL or %NULL
  */
 GstGLDisplayEGL *
 gst_gl_display_egl_new (void)
 {
   GstGLDisplayEGL *ret;
+  gpointer display;
 
   init_debug ();
 
-  ret = g_object_new (GST_TYPE_GL_DISPLAY_EGL, NULL);
-  gst_object_ref_sink (ret);
-  ret->display =
-      gst_gl_display_egl_get_from_native (GST_GL_DISPLAY_TYPE_ANY, 0);
+  display = gst_gl_display_egl_get_from_native (GST_GL_DISPLAY_TYPE_ANY, 0);
 
-  if (!ret->display) {
+  if (!display) {
     GST_INFO ("Failed to open EGL display connection");
+    return NULL;
   }
 
+  ret = g_object_new (GST_TYPE_GL_DISPLAY_EGL, NULL);
+  gst_object_ref_sink (ret);
+  ret->display = display;
+
   return ret;
 }
 
@@ -314,7 +317,7 @@ _ref_if_set (gpointer data, gpointer user_data)
  * This function will return the same value for multiple calls with the same
  * @display.
  *
- * Returns: (transfer full): a new #GstGLDisplayEGL
+ * Returns: (transfer full) (nullable): a new #GstGLDisplayEGL
  *
  * Since: 1.12
  */
index 47a4ffe..84fdddb 100644 (file)
@@ -90,7 +90,7 @@ gst_gl_display_egl_device_get_handle (GstGLDisplay * display)
  *
  * Create a new #GstGLDisplayEGLDevice with an EGLDevice supported device
  *
- * Returns: (transfer full): a new #GstGLDisplayEGLDevice or %NULL
+ * Returns: (transfer full) (nullable): a new #GstGLDisplayEGLDevice or %NULL
  *
  * Since: 1.18
  */
index e182eb6..483643a 100644 (file)
@@ -666,7 +666,7 @@ gst_gl_allocation_params_init (GstGLAllocationParams * params,
  * @src: the #GstGLAllocationParams to initialize
  *
  * Returns: (transfer full): a copy of the #GstGLAllocationParams specified by
- *          @src or %NULL on failure
+ *          @src
  *
  * Since: 1.8
  */
@@ -751,7 +751,7 @@ G_DEFINE_BOXED_TYPE (GstGLAllocationParams, gst_gl_allocation_params,
  * @allocator: a #GstGLBaseMemoryAllocator
  * @params: the #GstGLAllocationParams to allocate the memory with
  *
- * Returns: a new #GstGLBaseMemory from @allocator with the requested @params.
+ * Returns: (transfer full) (nullable): a new #GstGLBaseMemory from @allocator with the requested @params.
  *
  * Since: 1.8
  */
index 198c629..8a5fc0b 100644 (file)
@@ -261,7 +261,7 @@ void                    gst_gl_allocation_params_copy_data  (GstGLAllocationPara
  *
  * Note: not called with a GL context current
  *
- * Returns: a newly allocated #GstGLBaseMemory from @allocator and @params
+ * Returns: (transfer full) (nullable): a newly allocated #GstGLBaseMemory from @allocator and @params
  *
  * Since: 1.8
  */
@@ -318,7 +318,7 @@ typedef void                (*GstGLBaseMemoryAllocatorUnmapFunction)        (Gst
  *
  * Also see gst_memory_copy();
  *
- * Returns: the newly copied #GstGLMemory or %NULL
+ * Returns: (transfer full) (nullable): the newly copied #GstGLMemory or %NULL
  *
  * Since: 1.8
  */
index 7bf7888..168d483 100644 (file)
@@ -388,7 +388,7 @@ gst_gl_buffer_pool_finalize (GObject * object)
  * gst_buffer_pool_set_config() will cause this function to return a new
  * #GstGLAllocationParams which may or may not contain the same information.
  *
- * Returns: (transfer full): a copy of the #GstGLAllocationParams being used by the @pool
+ * Returns: (transfer full) (nullable): a copy of the #GstGLAllocationParams being used by the @pool
  *
  * Since: 1.20
  */
@@ -408,7 +408,7 @@ gst_gl_buffer_pool_get_gl_allocation_params (GstGLBufferPool * pool)
  * gst_buffer_pool_config_get_gl_allocation_params:
  * @config: a buffer pool config
  *
- * Returns: (transfer full): the currently set #GstGLAllocationParams or %NULL
+ * Returns: (transfer full) (nullable): the currently set #GstGLAllocationParams or %NULL
  */
 GstGLAllocationParams *
 gst_buffer_pool_config_get_gl_allocation_params (GstStructure * config)
@@ -425,7 +425,7 @@ gst_buffer_pool_config_get_gl_allocation_params (GstStructure * config)
 /**
  * gst_buffer_pool_config_set_gl_allocation_params:
  * @config: a buffer pool config
- * @params: (transfer none): a #GstGLAllocationParams
+ * @params: (transfer none) (nullable): a #GstGLAllocationParams
  *
  * Sets @params on @config
  */
index 78d0b37..f3656cf 100644 (file)
@@ -1525,7 +1525,7 @@ gst_gl_color_convert_fixate_caps (GstGLContext * context,
  * Converts the data contained by @inbuf using the formats specified by the
  * #GstCaps passed to gst_gl_color_convert_set_caps()
  *
- * Returns: (transfer full): a converted #GstBuffer or %NULL
+ * Returns: (transfer full) (nullable): a converted #GstBuffer or %NULL
  *
  * Since: 1.4
  */
index 4aab1a5..a0b1f06 100644 (file)
@@ -494,7 +494,7 @@ gst_gl_context_new_wrapped (GstGLDisplay * display, guintptr handle,
  * gst_gl_context_get_current_gl_context:
  * @context_type: a #GstGLPlatform specifying the type of context to retrieve
  *
- * Returns: The OpenGL context handle current in the calling thread or %NULL
+ * Returns: (nullable): The OpenGL context handle current in the calling thread or %NULL
  *
  * Since: 1.6
  */
@@ -543,7 +543,7 @@ gst_gl_context_get_current_gl_context (GstGLPlatform context_type)
  *
  * See also gst_gl_context_get_proc_address().
  *
- * Returns: a function pointer for @name, or %NULL
+ * Returns: (nullable): a function pointer for @name, or %NULL
  *
  * Since: 1.6
  */
@@ -807,7 +807,7 @@ gst_gl_context_activate (GstGLContext * context, gboolean activate)
  * gst_gl_context_get_thread:
  * @context: a #GstGLContext
  *
- * Returns: (transfer full): The #GThread, @context is current in or NULL
+ * Returns: (transfer full) (nullable): The #GThread, @context is current in or NULL
  *
  * Since: 1.6
  */
@@ -877,7 +877,7 @@ gst_gl_context_get_gl_api (GstGLContext * context)
  * void (GSTGLAPI *PFN_glGetIntegerv) (GLenum name, GLint * ret)
  * ]|
  *
- * Returns: a function pointer or %NULL
+ * Returns: (nullable): a function pointer or %NULL
  *
  * Since: 1.4
  */
@@ -908,7 +908,7 @@ gst_gl_context_get_proc_address (GstGLContext * context, const gchar * name)
  *
  * See also: gst_gl_context_get_proc_address()
  *
- * Returns: an address pointing to @name or %NULL
+ * Returns: (nullable): an address pointing to @name or %NULL
  *
  * Since: 1.4
  */
@@ -1770,7 +1770,7 @@ gst_gl_context_check_feature (GstGLContext * context, const gchar * feature)
  *
  * See also gst_gl_context_activate().
  *
- * Returns: (transfer none): the #GstGLContext active in the current thread or %NULL
+ * Returns: (transfer none) (nullable): the #GstGLContext active in the current thread or %NULL
  *
  * Since: 1.6
  */
index 08c369c..4857b9c 100644 (file)
@@ -168,7 +168,7 @@ gst_gl_display_class_init (GstGLDisplayClass * klass)
    * It can be called in any thread and it is emitted with
    * display's object lock held.
    *
-   * Returns: (transfer full): the new context.
+   * Returns: (transfer full) (nullable): the new context.
    */
   gst_gl_display_signals[CREATE_CONTEXT] =
       g_signal_new ("create-context", G_TYPE_FROM_CLASS (klass),
@@ -566,7 +566,7 @@ gst_gl_display_get_handle_type (GstGLDisplay * display)
 /**
  * gst_context_set_gl_display:
  * @context: a #GstContext
- * @display: (transfer none): resulting #GstGLDisplay
+ * @display: (transfer none) (nullable): resulting #GstGLDisplay
  *
  * Sets @display on @context
  *
@@ -592,7 +592,7 @@ gst_context_set_gl_display (GstContext * context, GstGLDisplay * display)
 /**
  * gst_context_get_gl_display:
  * @context: a #GstContext
- * @display: (out) (transfer full): resulting #GstGLDisplay
+ * @display: (out) (optional) (nullable) (transfer full): resulting #GstGLDisplay
  *
  * Returns: Whether @display was in @context
  *
@@ -622,7 +622,7 @@ gst_context_get_gl_display (GstContext * context, GstGLDisplay ** display)
  * @display: a #GstGLDisplay
  * @other_context: (transfer none): other #GstGLContext to share resources with.
  * @p_context: (transfer full) (out): resulting #GstGLContext
- * @error: (allow-none): resulting #GError
+ * @error: (optional): resulting #GError
  *
  * It requires the display's object lock to be held.
  *
@@ -674,7 +674,7 @@ gst_gl_display_create_context (GstGLDisplay * display,
  * gst_gl_display_create_window:
  * @display: a #GstGLDisplay
  *
- * Returns: (transfer full): a new #GstGLWindow for @display or %NULL.
+ * Returns: (transfer full) (nullable): a new #GstGLWindow for @display or %NULL.
  */
 /* XXX: previous versions had documentation requiring the OBJECT lock to be
  * held when this fuction is called so that needs to always work. */
@@ -746,7 +746,7 @@ gst_gl_display_remove_window (GstGLDisplay * display, GstGLWindow * window)
  * first argument to @compare_func is the #GstGLWindow being checked and the
  * second argument is @data.
  *
- * Returns: (transfer none): The first #GstGLWindow that causes a match
+ * Returns: (transfer none) (nullable): The first #GstGLWindow that causes a match
  *          from @compare_func
  *
  * Since: 1.12
@@ -776,7 +776,7 @@ gst_gl_display_find_window (GstGLDisplay * display, gpointer data,
  * first argument to @compare_func is the #GstGLWindow being checked and the
  * second argument is @data.
  *
- * Returns: (transfer full): The first #GstGLWindow that causes a match
+ * Returns: (transfer full) (nullable): The first #GstGLWindow that causes a match
  *          from @compare_func
  *
  * Since: 1.18
@@ -852,7 +852,7 @@ _get_gl_context_for_thread_unlocked (GstGLDisplay * display, GThread * thread)
  * @display: a #GstGLDisplay
  * @thread: a #GThread
  *
- * Returns: (transfer full): the #GstGLContext current on @thread or %NULL
+ * Returns: (transfer full) (nullable): the #GstGLContext current on @thread or %NULL
  *
  * Must be called with the object lock held.
  *
index 2649056..74ce48b 100644 (file)
@@ -495,7 +495,7 @@ gst_gl_format_is_supported (GstGLContext * context, GstGLFormat format)
  * gst_gl_texture_target_to_string:
  * @target: a #GstGLTextureTarget
  *
- * Returns: the stringified version of @target or %NULL
+ * Returns: (nullable): the stringified version of @target or %NULL
  */
 const gchar *
 gst_gl_texture_target_to_string (GstGLTextureTarget target)
@@ -583,7 +583,7 @@ gst_gl_texture_target_from_gl (guint target)
  * gst_gl_texture_target_to_buffer_pool_option:
  * @target: a #GstGLTextureTarget
  *
- * Returns: a string representing the @GstBufferPoolOption specified by @target
+ * Returns: (nullable): a string representing the @GstBufferPoolOption specified by @target
  */
 const gchar *
 gst_gl_texture_target_to_buffer_pool_option (GstGLTextureTarget target)
index 09bdda4..701912b 100644 (file)
@@ -266,7 +266,7 @@ _new_with_stages_va_list (GstGLContext * context, GError ** error,
 /**
  * gst_gl_shader_new_link_with_stages:
  * @context: a #GstGLContext
- * @error: a #GError
+ * @error: (optional): a #GError
  * @...: a NULL terminated list of #GstGLSLStage's
  *
  * Each stage will attempt to be compiled and attached to @shader.  Then
@@ -302,7 +302,7 @@ gst_gl_shader_new_link_with_stages (GstGLContext * context, GError ** error,
 /**
  * gst_gl_shader_new_with_stages:
  * @context: a #GstGLContext
- * @error: a #GError
+ * @error: (optional): a #GError
  * @...: a NULL terminated list of #GstGLSLStage's
  *
  * Each stage will attempt to be compiled and attached to @shader.  On error,
@@ -344,7 +344,7 @@ gst_gl_shader_new (GstGLContext * context)
 /**
  * gst_gl_shader_new_default:
  * @context: a #GstGLContext
- * @error: a #GError that is filled on failure
+ * @error: (optional): a #GError that is filled on failure
  *
  * Note: must be called in the GL thread
  *
@@ -594,7 +594,7 @@ gst_gl_shader_attach (GstGLShader * shader, GstGLSLStage * stage)
  * gst_gl_shader_compile_attach_stage:
  * @shader: a #GstGLShader
  * @stage: a #GstGLSLStage to attach
- * @error: a #GError
+ * @error: (optional): a #GError
  *
  * Compiles @stage and attaches it to @shader.
  *
@@ -626,7 +626,7 @@ gst_gl_shader_compile_attach_stage (GstGLShader * shader, GstGLSLStage * stage,
 /**
  * gst_gl_shader_link:
  * @shader: a #GstGLShader
- * @error: a #GError
+ * @error: (optional): a #GError
  *
  * Links the current list of #GstGLSLStage's in @shader.
  *
index 63dbcb7..67a0895 100644 (file)
@@ -237,7 +237,7 @@ _is_valid_version_profile (GstGLSLVersion version, GstGLSLProfile profile)
  * @version: a #GstGLSLVersion
  * @profile: a #GstGLSLVersion
  *
- * Returns: the combined GLSL `#version` string for @version and @profile
+ * Returns: (nullable): the combined GLSL `#version` string for @version and @profile
  */
 gchar *
 gst_glsl_version_profile_to_string (GstGLSLVersion version,
index 6931f91..7a76945 100644 (file)
@@ -1444,7 +1444,7 @@ gst_gl_view_convert_get_property (GObject * object, guint prop_id,
  * Converts the data contained by @inbuf using the formats specified by the
  * #GstCaps passed to gst_gl_view_convert_set_caps()
  *
- * Returns: (transfer full): a converted #GstBuffer or %NULL
+ * Returns: (transfer full) (nullable): a converted #GstBuffer or %NULL
  *
  * Since: 1.6
  */
index b90273e..56ad5b2 100644 (file)
@@ -71,7 +71,7 @@ gst_gl_display_viv_fb_finalize (GObject * object)
  *
  * Create a new #GstGLDisplayVivFB from the FB display index.
  *
- * Returns: (transfer full): a new #GstGLDisplayVivFB or %NULL
+ * Returns: (transfer full) (nullable): a new #GstGLDisplayVivFB or %NULL
  */
 GstGLDisplayVivFB *
 gst_gl_display_viv_fb_new (gint disp_idx)
index e1f406f..2949324 100644 (file)
@@ -92,7 +92,7 @@ gst_gl_display_wayland_finalize (GObject * object)
  * Create a new #GstGLDisplayWayland from the wayland display name.  See `wl_display_connect`()
  * for details on what is a valid name.
  *
- * Returns: (transfer full): a new #GstGLDisplayWayland or %NULL
+ * Returns: (transfer full) (nullable): a new #GstGLDisplayWayland or %NULL
  */
 GstGLDisplayWayland *
 gst_gl_display_wayland_new (const gchar * name)
index 9a8bf1f..d98e5f7 100644 (file)
@@ -91,7 +91,7 @@ gst_gl_display_x11_finalize (GObject * object)
  * Create a new #GstGLDisplayX11 from the x11 display name.  See `XOpenDisplay`()
  * for details on what is a valid name.
  *
- * Returns: (transfer full): a new #GstGLDisplayX11 or %NULL
+ * Returns: (transfer full) (nullable): a new #GstGLDisplayX11 or %NULL
  */
 GstGLDisplayX11 *
 gst_gl_display_x11_new (const gchar * name)