mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-23 00:36:51 +00:00
vulkan/decoder: don't initialize function table once
Since it has to be associated with the device and it gets destroyed when the decoder is freed. Now it's created when the decoder starts and it's flagged. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6089>
This commit is contained in:
parent
bf936fa6c0
commit
f0c5a853a6
1 changed files with 11 additions and 10 deletions
|
@ -53,6 +53,8 @@ struct _GstVulkanDecoderPrivate
|
|||
GstVulkanVideoSession session;
|
||||
GstVulkanVideoCapabilities caps;
|
||||
VkVideoFormatPropertiesKHR format;
|
||||
|
||||
gboolean vk_populated;
|
||||
GstVulkanVideoFunctions vk;
|
||||
|
||||
gboolean started;
|
||||
|
@ -71,24 +73,25 @@ static GstVulkanHandle *gst_vulkan_decoder_new_video_session_parameters
|
|||
(GstVulkanDecoder * self, GstVulkanDecoderParameters * params,
|
||||
GError ** error);
|
||||
|
||||
static gpointer
|
||||
_populate_function_table (gpointer data)
|
||||
static gboolean
|
||||
_populate_function_table (GstVulkanDecoder * self)
|
||||
{
|
||||
GstVulkanDecoder *self = GST_VULKAN_DECODER (data);
|
||||
GstVulkanDecoderPrivate *priv =
|
||||
gst_vulkan_decoder_get_instance_private (self);
|
||||
GstVulkanInstance *instance;
|
||||
gboolean ret = FALSE;
|
||||
|
||||
if (priv->vk_populated)
|
||||
return TRUE;
|
||||
|
||||
instance = gst_vulkan_device_get_instance (self->queue->device);
|
||||
if (!instance) {
|
||||
GST_ERROR_OBJECT (self, "Failed to get instance from the device");
|
||||
return GINT_TO_POINTER (FALSE);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
ret = gst_vulkan_video_get_vk_functions (instance, &priv->vk);
|
||||
priv->vk_populated = gst_vulkan_video_get_vk_functions (instance, &priv->vk);
|
||||
gst_object_unref (instance);
|
||||
return GINT_TO_POINTER (ret);
|
||||
return priv->vk_populated;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -144,7 +147,6 @@ gst_vulkan_decoder_start (GstVulkanDecoder * self,
|
|||
};
|
||||
VkVideoSessionCreateInfoKHR session_create;
|
||||
GstVulkanDecoderParameters empty_params;
|
||||
static GOnce once = G_ONCE_INIT;
|
||||
guint i, maxlevel, n_fmts, codec_idx;
|
||||
GstVideoFormat format = GST_VIDEO_FORMAT_UNKNOWN;
|
||||
VkFormat vk_format = VK_FORMAT_UNDEFINED;
|
||||
|
@ -160,8 +162,7 @@ gst_vulkan_decoder_start (GstVulkanDecoder * self,
|
|||
|
||||
g_assert (self->codec == profile->profile.videoCodecOperation);
|
||||
|
||||
g_once (&once, _populate_function_table, self);
|
||||
if (GPOINTER_TO_INT (once.retval) == FALSE) {
|
||||
if (!_populate_function_table (self)) {
|
||||
g_set_error (error, GST_VULKAN_ERROR, VK_ERROR_INITIALIZATION_FAILED,
|
||||
"Couldn't load Vulkan Video functions");
|
||||
return FALSE;
|
||||
|
|
Loading…
Reference in a new issue