From 2f0e19570911da8f0c3fa1e89550e31dc9c8860f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sebastian=20Dr=C3=B6ge?= Date: Mon, 17 Oct 2022 11:29:02 +0300 Subject: [PATCH] vulkan: Add/fix various annotations And fix a memory leak in gst_vulkan_display_wayland_new() in error cases. Part-of: --- .../gst-libs/gst/vulkan/android/gstvkdisplay_android.c | 2 +- .../gst-libs/gst/vulkan/cocoa/gstvkdisplay_cocoa.m | 2 +- .../gst-plugins-bad/gst-libs/gst/vulkan/gstvkdevice.c | 6 +++--- .../gst-plugins-bad/gst-libs/gst/vulkan/gstvkdisplay.c | 8 ++++---- .../gst-plugins-bad/gst-libs/gst/vulkan/gstvkfence.c | 2 +- .../gst-plugins-bad/gst-libs/gst/vulkan/gstvkformat.c | 2 +- .../gst-plugins-bad/gst-libs/gst/vulkan/gstvkinstance.c | 3 ++- .../gst-plugins-bad/gst-libs/gst/vulkan/gstvkqueue.c | 4 ++-- .../gst-plugins-bad/gst-libs/gst/vulkan/gstvkutils.c | 2 +- .../gst-libs/gst/vulkan/ios/gstvkdisplay_ios.m | 2 +- .../gst-libs/gst/vulkan/wayland/gstvkdisplay_wayland.c | 15 +++++++++------ .../gst-libs/gst/vulkan/xcb/gstvkdisplay_xcb.c | 4 ++-- 12 files changed, 28 insertions(+), 24 deletions(-) diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/android/gstvkdisplay_android.c b/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/android/gstvkdisplay_android.c index 5a4156d..79f5f73 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/android/gstvkdisplay_android.c +++ b/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/android/gstvkdisplay_android.c @@ -64,7 +64,7 @@ gst_vulkan_display_android_finalize (GObject * object) * * Create a new #GstVulkanDisplayAndroid. * - * Returns: (transfer full): a new #GstVulkanDisplayAndroid or %NULL + * Returns: (transfer full): a new #GstVulkanDisplayAndroid */ GstVulkanDisplayAndroid * gst_vulkan_display_android_new (void) diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/cocoa/gstvkdisplay_cocoa.m b/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/cocoa/gstvkdisplay_cocoa.m index 27519a6..6daa53d 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/cocoa/gstvkdisplay_cocoa.m +++ b/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/cocoa/gstvkdisplay_cocoa.m @@ -221,7 +221,7 @@ gst_vulkan_display_cocoa_finalize (GObject * object) * * Create a new #GstVulkanDisplayCocoa. * - * Returns: (transfer full): a new #GstVulkanDisplayCocoa or %NULL + * Returns: (transfer full): a new #GstVulkanDisplayCocoa */ GstVulkanDisplayCocoa * gst_vulkan_display_cocoa_new (void) diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkdevice.c b/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkdevice.c index 639406d..005bf98 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkdevice.c +++ b/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkdevice.c @@ -424,7 +424,7 @@ gst_vulkan_device_foreach_queue (GstVulkanDevice * device, * * Performs `vkGetDeviceProcAddr()` with @device and @name * - * Returns: the function pointer for @name or %NULL + * Returns: (nullable): the function pointer for @name or %NULL * * Since: 1.18 */ @@ -445,7 +445,7 @@ gst_vulkan_device_get_proc_address (GstVulkanDevice * device, * gst_vulkan_device_get_instance: * @device: a #GstVulkanDevice * - * Returns: (transfer full): the #GstVulkanInstance used to create this @device + * Returns: (transfer full) (nullable): the #GstVulkanInstance used to create this @device * * Since: 1.18 */ @@ -629,7 +629,7 @@ gst_vulkan_device_run_context_query (GstElement * element, * @device: a #GstVulkanDevice * @error: a #GError to fill on failure * - * Returns: a new #GstVulkanFence or %NULL + * Returns: (transfer full) (nullable): a new #GstVulkanFence or %NULL * * Since: 1.18 */ diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkdisplay.c b/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkdisplay.c index fc87417..82756d7 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkdisplay.c +++ b/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkdisplay.c @@ -206,7 +206,7 @@ gst_vulkan_display_finalize (GObject * object) * @instance: a #GstVulkanInstance * @type: the #GstVulkanDisplayType to create * - * Returns: (transfer full): a new #GstVulkanDisplay or %NULL if e.g. @type is + * Returns: (transfer full) (nullable): a new #GstVulkanDisplay or %NULL if e.g. @type is * unsupported * * Since: 1.18 @@ -326,7 +326,7 @@ gst_vulkan_display_get_handle_type (GstVulkanDisplay * display) * gst_vulkan_display_create_window: * @display: a #GstVulkanDisplay * - * Returns: (transfer full): a new #GstVulkanWindow for @display or %NULL. + * Returns: (transfer full) (nullable): a new #GstVulkanWindow for @display or %NULL. * * Since: 1.18 */ @@ -400,7 +400,7 @@ window_weak_list_to_strong (GstVulkanDisplay * display) * first argument to @compare_func is the #GstVulkanWindow being checked and the * second argument is @data. * - * Returns: (transfer full): The first #GstVulkanWindow that causes a match + * Returns: (transfer full) (nullable): The first #GstVulkanWindow that causes a match * from @compare_func * * Since: 1.18 @@ -633,7 +633,7 @@ gst_vulkan_display_choose_type (GstVulkanInstance * instance) * gst_vulkan_display_type_to_extension_string: * @type: a #GstVulkanDisplayType * - * Returns: the Vulkan extension string required for creating a VkSurfaceKHR + * Returns: (nullable): the Vulkan extension string required for creating a VkSurfaceKHR * using a window system handle or %NULL * * Since: 1.18 diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkfence.c b/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkfence.c index 9e03a24..c2db919 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkfence.c +++ b/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkfence.c @@ -87,7 +87,7 @@ gst_vulkan_fence_free (GstVulkanFence * fence) /** * gst_vulkan_fence_new: * @device: the parent #GstVulkanDevice - * @error: a #GError for the failure condition + * @error: (optional): a #GError for the failure condition * * Returns: whether a new #GstVulkanFence or %NULL on error * diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkformat.c b/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkformat.c index 4d18685..98fe222 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkformat.c +++ b/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkformat.c @@ -419,7 +419,7 @@ FIXME: implement: * gst_vulkan_format_get_info: * @format: a valid `VkFormat` * - * Returns: the #GstVulkanFormatInfo for @format or %NULL + * Returns: (nullable): the #GstVulkanFormatInfo for @format or %NULL * * Since: 1.18 */ diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkinstance.c b/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkinstance.c index 46f9148..58631fc 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkinstance.c +++ b/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkinstance.c @@ -1071,7 +1071,7 @@ error: * * Performs `vkGetInstanceProcAddr()` with @instance and @name * - * Returns: the function pointer for @name or %NULL + * Returns: (nullable): the function pointer for @name or %NULL * * Since: 1.18 */ @@ -1095,6 +1095,7 @@ gst_vulkan_instance_get_proc_address (GstVulkanInstance * instance, /** * gst_vulkan_instance_create_device: * @instance: a #GstVulkanInstance + * @error: (optional): a #GError * * Returns: (transfer full): a new #GstVulkanDevice * diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkqueue.c b/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkqueue.c index 025b9b2..b462557 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkqueue.c +++ b/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkqueue.c @@ -97,7 +97,7 @@ gst_vulkan_queue_dispose (GObject * object) * gst_vulkan_queue_get_device * @queue: a #GstVulkanQueue * - * Returns: (transfer full): the #GstVulkanDevice for @queue + * Returns: (transfer full) (nullable): the #GstVulkanDevice for @queue * * Since: 1.18 */ @@ -112,7 +112,7 @@ gst_vulkan_queue_get_device (GstVulkanQueue * queue) /** * gst_vulkan_queue_create_command_pool: * @queue: a #GstVulkanQueue - * @error: a #GError + * @error: (optional): a #GError * * Returns: (transfer full): a new #GstVUlkanCommandPool or %NULL * diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkutils.c b/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkutils.c index 7f28d25..d17bc26 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkutils.c +++ b/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkutils.c @@ -489,7 +489,7 @@ gst_vulkan_get_or_create_image_view (GstVulkanImageMemory * image) * @device: a #GstVulkanDevice * @code: the SPIR-V shader byte code * @size: length of @code. Must be a multiple of 4 - * @error: a #GError to fill on failure + * @error: (optional): a #GError to fill on failure * * Returns: (transfer full): a #GstVulkanHandle for @image matching the * original layout and format of @image or %NULL diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/ios/gstvkdisplay_ios.m b/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/ios/gstvkdisplay_ios.m index 0bd3ff7..9b018fe 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/ios/gstvkdisplay_ios.m +++ b/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/ios/gstvkdisplay_ios.m @@ -65,7 +65,7 @@ gst_vulkan_display_ios_finalize (GObject * object) * * Create a new #GstVulkanDisplayIos. * - * Returns: (transfer full): a new #GstVulkanDisplayIos or %NULL + * Returns: (transfer full): a new #GstVulkanDisplayIos */ GstVulkanDisplayIos * gst_vulkan_display_ios_new (void) diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/wayland/gstvkdisplay_wayland.c b/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/wayland/gstvkdisplay_wayland.c index ae9c172..7aa7465 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/wayland/gstvkdisplay_wayland.c +++ b/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/wayland/gstvkdisplay_wayland.c @@ -105,12 +105,12 @@ gst_vulkan_display_wayland_finalize (GObject * object) /** * gst_vulkan_display_wayland_new: - * @name: (allow-none): a display name + * @name: (nullable): a display name * * Create a new #GstVulkanDisplayWayland from the wayland display name. See `wl_display_connect`() * for details on what is a valid name. * - * Returns: (transfer full): a new #GstVulkanDisplayWayland or %NULL + * Returns: (transfer full) (nullable): a new #GstVulkanDisplayWayland or %NULL * * Since: 1.18 */ @@ -118,17 +118,20 @@ GstVulkanDisplayWayland * gst_vulkan_display_wayland_new (const gchar * name) { GstVulkanDisplayWayland *ret; + struct wl_display *display; - ret = g_object_new (GST_TYPE_VULKAN_DISPLAY_WAYLAND, NULL); - gst_object_ref_sink (ret); - ret->display = wl_display_connect (name); + display = wl_display_connect (name); - if (!ret->display) { + if (!display) { GST_ERROR ("Failed to open Wayland display connection with name, \'%s\'", name); return NULL; } + ret = g_object_new (GST_TYPE_VULKAN_DISPLAY_WAYLAND, NULL); + gst_object_ref_sink (ret); + ret->display = display; + /* connecting the listeners after attaching the event source will race with * the source and the source may eat an event that we're waiting for and * deadlock */ diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/xcb/gstvkdisplay_xcb.c b/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/xcb/gstvkdisplay_xcb.c index fb07c94..a9f0349 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/xcb/gstvkdisplay_xcb.c +++ b/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/xcb/gstvkdisplay_xcb.c @@ -82,12 +82,12 @@ _get_screen_from_connection (xcb_connection_t * connection, int screen_no) /** * gst_vulkan_display_xcb_new: - * @name: (allow-none): a display name + * @name: (nullable): a display name * * Create a new #GstVulkanDisplayXCB from the xcb display name. See XOpenDisplay\() * for details on what is a valid name. * - * Returns: (transfer full): a new #GstVulkanDisplayXCB or %NULL + * Returns: (transfer full) (nullable): a new #GstVulkanDisplayXCB or %NULL * * Since: 1.18 */ -- 2.7.4