From d2b85683de19ecfd765149bcace27e0138610d67 Mon Sep 17 00:00:00 2001 From: Seungha Yang Date: Wed, 4 Dec 2019 23:20:39 +0900 Subject: [PATCH] d3d11device: Add gst_d3d11_device_thread_add_full method I would be used to invoke GPU task with specified priority. --- sys/d3d11/gstd3d11device.c | 26 ++++++++++++++++++++++++-- sys/d3d11/gstd3d11device.h | 6 ++++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/sys/d3d11/gstd3d11device.c b/sys/d3d11/gstd3d11device.c index 0dfcd1bb69..3f054c5603 100644 --- a/sys/d3d11/gstd3d11device.c +++ b/sys/d3d11/gstd3d11device.c @@ -652,6 +652,28 @@ gst_d3d11_device_message_callback (MessageData * msg) void gst_d3d11_device_thread_add (GstD3D11Device * device, GstD3D11DeviceThreadFunc func, gpointer data) +{ + gst_d3d11_device_thread_add_full (device, + G_PRIORITY_DEFAULT, func, data, NULL); +} + +/** + * gst_d3d11_device_thread_add_full: + * @device: a #GstD3D11Device + * @priority: the priority at which to run @func + * @func: (scope call): a #GstD3D11DeviceThreadFunc + * @data: (closure): user data to call @func with + * @notify: (nullable): a function to call when @data is no longer in use, or %NULL. + * + * Execute @func in the D3DDevice thread of @device with @data with specified + * @priority + * + * MT-safe + */ +void +gst_d3d11_device_thread_add_full (GstD3D11Device * device, + gint priority, GstD3D11DeviceThreadFunc func, gpointer data, + GDestroyNotify notify) { GstD3D11DevicePrivate *priv; MessageData msg = { 0, }; @@ -671,8 +693,8 @@ gst_d3d11_device_thread_add (GstD3D11Device * device, msg.data = data; msg.fired = FALSE; - g_main_context_invoke (priv->main_context, - (GSourceFunc) gst_d3d11_device_message_callback, &msg); + g_main_context_invoke_full (priv->main_context, priority, + (GSourceFunc) gst_d3d11_device_message_callback, &msg, notify); g_mutex_lock (&priv->lock); while (!msg.fired) diff --git a/sys/d3d11/gstd3d11device.h b/sys/d3d11/gstd3d11device.h index ad76c9c17c..ee1dc58f96 100644 --- a/sys/d3d11/gstd3d11device.h +++ b/sys/d3d11/gstd3d11device.h @@ -97,6 +97,12 @@ void gst_d3d11_device_thread_add (GstD3D11Device * devi GstD3D11DeviceThreadFunc func, gpointer data); +void gst_d3d11_device_thread_add_full (GstD3D11Device * device, + gint priority, + GstD3D11DeviceThreadFunc func, + gpointer data, + GDestroyNotify notify); + ID3D11Texture2D * gst_d3d11_device_create_texture (GstD3D11Device * device, const D3D11_TEXTURE2D_DESC * desc, const D3D11_SUBRESOURCE_DATA *inital_data);