From d3b3a1c00abae8d77efbfd3f7c8c794f547b2833 Mon Sep 17 00:00:00 2001 From: Seungha Yang Date: Wed, 3 Jan 2024 01:15:27 +0900 Subject: [PATCH] d3d12: Add {set,get}_user_data() methods to command allocator Part-of: --- .../d3d12/gstd3d12commandallocatorpool.cpp | 29 +++++++++++++++++++ .../sys/d3d12/gstd3d12commandallocatorpool.h | 6 ++++ 2 files changed, 35 insertions(+) diff --git a/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12commandallocatorpool.cpp b/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12commandallocatorpool.cpp index 1fc5a7eb73..6423b4b3d0 100644 --- a/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12commandallocatorpool.cpp +++ b/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12commandallocatorpool.cpp @@ -34,9 +34,17 @@ using namespace Microsoft::WRL; struct _GstD3D12CommandAllocator : public GstMiniObject { + ~_GstD3D12CommandAllocator () + { + if (notify) + notify (user_data); + } + GstD3D12CommandAllocatorPool *pool = nullptr; D3D12_COMMAND_LIST_TYPE type; ComPtr < ID3D12CommandAllocator > ca; + gpointer user_data = nullptr; + GDestroyNotify notify = nullptr; }; struct GstD3D12CommandAllocatorPoolPrivate @@ -248,3 +256,24 @@ gst_d3d12_command_allocator_get_handle (GstD3D12CommandAllocator * cmd, return TRUE; } + +void +gst_d3d12_command_allocator_set_user_data (GstD3D12CommandAllocator * cmd, + gpointer user_data, GDestroyNotify notify) +{ + g_return_if_fail (cmd); + + if (cmd->notify) + cmd->notify (cmd->user_data); + + cmd->user_data = user_data; + cmd->notify = notify; +} + +gpointer +gst_d3d12_command_allocator_get_user_data (GstD3D12CommandAllocator * cmd) +{ + g_return_val_if_fail (cmd, nullptr); + + return cmd->user_data; +} diff --git a/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12commandallocatorpool.h b/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12commandallocatorpool.h index 761b291147..a835a1ba27 100644 --- a/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12commandallocatorpool.h +++ b/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12commandallocatorpool.h @@ -48,5 +48,11 @@ D3D12_COMMAND_LIST_TYPE gst_d3d12_command_allocator_get_command_type (Gst gboolean gst_d3d12_command_allocator_get_handle (GstD3D12CommandAllocator * cmd, ID3D12CommandAllocator ** ca); +void gst_d3d12_command_allocator_set_user_data (GstD3D12CommandAllocator * cmd, + gpointer user_data, + GDestroyNotify notify); + +gpointer gst_d3d12_command_allocator_get_user_data (GstD3D12CommandAllocator * cmd); + G_END_DECLS