1 /* 2 * GStreamer 3 * Copyright (C) 2019 Matthew Waters <matthew@centricular.com> 4 * 5 * This library is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU Library General Public 7 * License as published by the Free Software Foundation; either 8 * version 2 of the License, or (at your option) any later version. 9 * 10 * This library is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * Library General Public License for more details. 14 * 15 * You should have received a copy of the GNU Library General Public 16 * License along with this library; if not, write to the 17 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, 18 * Boston, MA 02110-1301, USA. 19 */ 20 21 #ifndef __GST_VULKAN_HANDLE_POOL_H__ 22 #define __GST_VULKAN_HANDLE_POOL_H__ 23 24 #include <gst/gst.h> 25 26 #include <gst/vulkan/vulkan_fwd.h> 27 #include <gst/vulkan/gstvkapi.h> 28 29 G_BEGIN_DECLS 30 31 GST_VULKAN_API 32 GType gst_vulkan_handle_pool_get_type (void); 33 #define GST_TYPE_VULKAN_HANDLE_POOL (gst_vulkan_handle_pool_get_type()) 34 #define GST_VULKAN_HANDLE_POOL(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_VULKAN_HANDLE_POOL,GstVulkanHandlePool)) 35 #define GST_VULKAN_HANDLE_POOL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_VULKAN_HANDLE_POOL,GstVulkanHandlePoolClass)) 36 #define GST_IS_VULKAN_HANDLE_POOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_VULKAN_HANDLE_POOL)) 37 #define GST_IS_VULKAN_HANDLE_POOL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_VULKAN_HANDLE_POOL)) 38 #define GST_VULKAN_HANDLE_POOL_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS((o), GST_TYPE_VULKAN_HANDLE_POOL, GstVulkanHandlePoolClass)) 39 /** 40 * GST_VULKAN_HANDLE_POOL_CAST: 41 * 42 * Since: 1.18 43 */ 44 #define GST_VULKAN_HANDLE_POOL_CAST(o) ((GstVulkanHandlePool *) o) 45 46 /** 47 * GstVulkanHandlePool: 48 * @parent: the parent #GstObject 49 * @device: the #GstVulkanDevice handles are allocated from 50 * @outstanding: the collection of outstanding handles 51 * @available: the collection of allocated and available handles 52 * 53 * Since: 1.18 54 */ 55 struct _GstVulkanHandlePool 56 { 57 GstObject parent; 58 59 GstVulkanDevice *device; 60 61 /* <protected> */ 62 GPtrArray *outstanding; 63 GPtrArray *available; 64 65 /* <private> */ 66 gpointer _padding[GST_PADDING]; 67 }; 68 69 /** 70 * GstVulkanHandlePoolClass: 71 * @parent: the parent #GstObjectClass 72 * @alloc: allocate a new handle 73 * @acquire: acquire a handle for usage 74 * @release: release a handle for possible reuse at the next call to @acquire 75 * @free: free a handle 76 * 77 * Since: 1.18 78 */ 79 struct _GstVulkanHandlePoolClass 80 { 81 GstObjectClass parent; 82 83 gpointer (*alloc) (GstVulkanHandlePool * pool, GError ** error); 84 gpointer (*acquire) (GstVulkanHandlePool * pool, GError ** error); 85 void (*release) (GstVulkanHandlePool * pool, gpointer handle); 86 void (*free) (GstVulkanHandlePool * pool, gpointer handle); 87 88 /* <private> */ 89 gpointer _padding[GST_PADDING]; 90 }; 91 92 G_DEFINE_AUTOPTR_CLEANUP_FUNC (GstVulkanHandlePool, gst_object_unref) 93 94 GST_VULKAN_API 95 gpointer gst_vulkan_handle_pool_alloc (GstVulkanHandlePool * pool, GError ** error); 96 GST_VULKAN_API 97 gpointer gst_vulkan_handle_pool_acquire (GstVulkanHandlePool * pool, GError ** error); 98 GST_VULKAN_API 99 void gst_vulkan_handle_pool_release (GstVulkanHandlePool * pool, gpointer handle); 100 101 G_END_DECLS 102 103 #endif /* _GST_VULKAN_HANDLE_H_ */ 104