vulkan: Use new GLib APIs as suggested by comments
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4349>
This commit is contained in:
parent
1c301df91a
commit
b90c0bd79b
@ -644,32 +644,14 @@ gst_vulkan_device_create_fence (GstVulkanDevice * device, GError ** error)
|
|||||||
return gst_vulkan_fence_cache_acquire (priv->fence_cache, error);
|
return gst_vulkan_fence_cache_acquire (priv->fence_cache, error);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* reimplement a specfic case of g_ptr_array_find_with_equal_func as that
|
|
||||||
* requires Glib 2.54 */
|
|
||||||
static gboolean
|
|
||||||
ptr_array_find_string (GPtrArray * array, const gchar * str, guint * index)
|
|
||||||
{
|
|
||||||
guint i;
|
|
||||||
|
|
||||||
for (i = 0; i < array->len; i++) {
|
|
||||||
gchar *val = (gchar *) g_ptr_array_index (array, i);
|
|
||||||
if (g_strcmp0 (val, str) == 0) {
|
|
||||||
if (index)
|
|
||||||
*index = i;
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_vulkan_device_is_extension_enabled_unlocked (GstVulkanDevice * device,
|
gst_vulkan_device_is_extension_enabled_unlocked (GstVulkanDevice * device,
|
||||||
const gchar * name, guint * index)
|
const gchar * name, guint * index)
|
||||||
{
|
{
|
||||||
GstVulkanDevicePrivate *priv = GET_PRIV (device);
|
GstVulkanDevicePrivate *priv = GET_PRIV (device);
|
||||||
|
|
||||||
return ptr_array_find_string (priv->enabled_extensions, name, index);
|
return g_ptr_array_find_with_equal_func (priv->enabled_extensions, name,
|
||||||
|
g_str_equal, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -798,7 +780,8 @@ gst_vulkan_device_is_layer_enabled_unlocked (GstVulkanDevice * device,
|
|||||||
{
|
{
|
||||||
GstVulkanDevicePrivate *priv = GET_PRIV (device);
|
GstVulkanDevicePrivate *priv = GET_PRIV (device);
|
||||||
|
|
||||||
return ptr_array_find_string (priv->enabled_layers, name, NULL);
|
return g_ptr_array_find_with_equal_func (priv->enabled_layers, name,
|
||||||
|
g_str_equal, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -555,8 +555,7 @@ gst_vulkan_image_memory_release_view (GstVulkanImageMemory * image,
|
|||||||
GST_CAT_TRACE (GST_CAT_VULKAN_IMAGE_MEMORY, "image %p removing view %p",
|
GST_CAT_TRACE (GST_CAT_VULKAN_IMAGE_MEMORY, "image %p removing view %p",
|
||||||
image, view);
|
image, view);
|
||||||
if (g_ptr_array_find (image->outstanding_views, view, &index)) {
|
if (g_ptr_array_find (image->outstanding_views, view, &index)) {
|
||||||
/* really g_ptr_array_steal_index_fast() but that requires glib 2.58 */
|
g_ptr_array_steal_index_fast (image->outstanding_views, index);
|
||||||
g_ptr_array_remove_index_fast (image->outstanding_views, index);
|
|
||||||
g_ptr_array_add (image->views, view);
|
g_ptr_array_add (image->views, view);
|
||||||
} else {
|
} else {
|
||||||
g_warning ("GstVulkanImageMemory:%p attempt to remove a view %p "
|
g_warning ("GstVulkanImageMemory:%p attempt to remove a view %p "
|
||||||
@ -654,8 +653,7 @@ gst_vulkan_image_memory_find_view (GstVulkanImageMemory * image,
|
|||||||
index));
|
index));
|
||||||
} else if (g_ptr_array_find_with_equal_func (image->views, &view,
|
} else if (g_ptr_array_find_with_equal_func (image->views, &view,
|
||||||
(GEqualFunc) find_view_func, &index)) {
|
(GEqualFunc) find_view_func, &index)) {
|
||||||
/* really g_ptr_array_steal_index_fast() but that requires glib 2.58 */
|
ret = g_ptr_array_steal_index_fast (image->views, index);
|
||||||
ret = g_ptr_array_remove_index_fast (image->views, index);
|
|
||||||
g_ptr_array_add (image->outstanding_views, ret);
|
g_ptr_array_add (image->outstanding_views, ret);
|
||||||
ret->image = (GstVulkanImageMemory *) gst_memory_ref ((GstMemory *) image);
|
ret->image = (GstVulkanImageMemory *) gst_memory_ref ((GstMemory *) image);
|
||||||
}
|
}
|
||||||
|
@ -456,32 +456,14 @@ gst_vulkan_instance_get_extension_info (GstVulkanInstance * instance,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* reimplement a specfic case of g_ptr_array_find_with_equal_func as that
|
|
||||||
* requires Glib 2.54 */
|
|
||||||
static gboolean
|
|
||||||
ptr_array_find_string (GPtrArray * array, const gchar * str, guint * index)
|
|
||||||
{
|
|
||||||
guint i;
|
|
||||||
|
|
||||||
for (i = 0; i < array->len; i++) {
|
|
||||||
gchar *val = (gchar *) g_ptr_array_index (array, i);
|
|
||||||
if (g_strcmp0 (val, str) == 0) {
|
|
||||||
if (index)
|
|
||||||
*index = i;
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_vulkan_instance_is_extension_enabled_unlocked (GstVulkanInstance * instance,
|
gst_vulkan_instance_is_extension_enabled_unlocked (GstVulkanInstance * instance,
|
||||||
const gchar * name, guint * index)
|
const gchar * name, guint * index)
|
||||||
{
|
{
|
||||||
GstVulkanInstancePrivate *priv = GET_PRIV (instance);
|
GstVulkanInstancePrivate *priv = GET_PRIV (instance);
|
||||||
|
|
||||||
return ptr_array_find_string (priv->enabled_extensions, name, index);
|
return g_ptr_array_find_with_equal_func (priv->enabled_extensions, name,
|
||||||
|
g_str_equal, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -627,7 +609,8 @@ gst_vulkan_instance_is_layer_enabled_unlocked (GstVulkanInstance * instance,
|
|||||||
{
|
{
|
||||||
GstVulkanInstancePrivate *priv = GET_PRIV (instance);
|
GstVulkanInstancePrivate *priv = GET_PRIV (instance);
|
||||||
|
|
||||||
return ptr_array_find_string (priv->enabled_layers, name, NULL);
|
return g_ptr_array_find_with_equal_func (priv->enabled_layers, name,
|
||||||
|
g_str_equal, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user