2019-08-19 09:02:56 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) <2018-2019> Seungha Yang <seungha.yang@navercorp.com>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "gstcudabufferpool.h"
|
|
|
|
#include "gstcudacontext.h"
|
|
|
|
#include "gstcudamemory.h"
|
2023-06-03 15:53:40 +00:00
|
|
|
#include "gstcuda-private.h"
|
2019-08-19 09:02:56 +00:00
|
|
|
|
|
|
|
GST_DEBUG_CATEGORY_STATIC (gst_cuda_buffer_pool_debug);
|
|
|
|
#define GST_CAT_DEFAULT gst_cuda_buffer_pool_debug
|
|
|
|
|
|
|
|
struct _GstCudaBufferPoolPrivate
|
|
|
|
{
|
|
|
|
GstVideoInfo info;
|
2022-12-22 15:37:36 +00:00
|
|
|
GstCudaStream *stream;
|
|
|
|
GstCudaPoolAllocator *alloc;
|
2023-06-03 15:53:40 +00:00
|
|
|
GstCudaMemoryAllocMethod alloc_method;
|
|
|
|
CUmemAllocationProp prop;
|
2019-08-19 09:02:56 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#define gst_cuda_buffer_pool_parent_class parent_class
|
|
|
|
G_DEFINE_TYPE_WITH_PRIVATE (GstCudaBufferPool, gst_cuda_buffer_pool,
|
|
|
|
GST_TYPE_BUFFER_POOL);
|
|
|
|
|
|
|
|
static const gchar **
|
|
|
|
gst_cuda_buffer_pool_get_options (GstBufferPool * pool)
|
|
|
|
{
|
2023-02-05 10:50:36 +00:00
|
|
|
static const gchar *options[] = { GST_BUFFER_POOL_OPTION_VIDEO_META, nullptr
|
2019-08-19 09:02:56 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
return options;
|
|
|
|
}
|
|
|
|
|
2023-06-03 15:53:40 +00:00
|
|
|
static gboolean
|
|
|
|
gst_cuda_buffer_pool_update_alloc_prop (GstCudaBufferPool * self)
|
|
|
|
{
|
|
|
|
GstCudaBufferPoolPrivate *priv = self->priv;
|
|
|
|
gboolean virtual_mem_supported;
|
|
|
|
gboolean os_handle_supported;
|
|
|
|
guint device;
|
|
|
|
|
|
|
|
g_object_get (self->context, "cuda-device-id", &device,
|
|
|
|
"virtual-memory", &virtual_mem_supported,
|
|
|
|
"os-handle", &os_handle_supported, nullptr);
|
|
|
|
|
|
|
|
if (!virtual_mem_supported) {
|
|
|
|
GST_DEBUG_OBJECT (self, "Virtual memory management is not supported");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!os_handle_supported) {
|
|
|
|
GST_DEBUG_OBJECT (self, "OS handle is not supported");;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
priv->prop.type = CU_MEM_ALLOCATION_TYPE_PINNED;
|
|
|
|
priv->prop.location.type = CU_MEM_LOCATION_TYPE_DEVICE;
|
|
|
|
priv->prop.location.id = (int) device;
|
|
|
|
#ifdef G_OS_WIN32
|
|
|
|
priv->prop.requestedHandleTypes = CU_MEM_HANDLE_TYPE_WIN32;
|
|
|
|
priv->prop.win32HandleMetaData = gst_cuda_get_win32_handle_metadata ();
|
|
|
|
#else
|
|
|
|
priv->prop.requestedHandleTypes = CU_MEM_HANDLE_TYPE_POSIX_FILE_DESCRIPTOR;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2024-09-10 10:29:44 +00:00
|
|
|
static gboolean
|
|
|
|
default_stream_ordered_alloc_enabled (void)
|
|
|
|
{
|
|
|
|
static gboolean enabled = FALSE;
|
|
|
|
GST_CUDA_CALL_ONCE_BEGIN {
|
|
|
|
if (g_getenv ("GST_CUDA_ENABLE_STREAM_ORDERED_ALLOC"))
|
|
|
|
enabled = TRUE;
|
|
|
|
}
|
|
|
|
GST_CUDA_CALL_ONCE_END;
|
|
|
|
|
|
|
|
return enabled;
|
|
|
|
}
|
|
|
|
|
2019-08-19 09:02:56 +00:00
|
|
|
static gboolean
|
|
|
|
gst_cuda_buffer_pool_set_config (GstBufferPool * pool, GstStructure * config)
|
|
|
|
{
|
2022-03-02 18:25:47 +00:00
|
|
|
GstCudaBufferPool *self = GST_CUDA_BUFFER_POOL (pool);
|
|
|
|
GstCudaBufferPoolPrivate *priv = self->priv;
|
2023-02-05 10:50:36 +00:00
|
|
|
GstCaps *caps = nullptr;
|
2019-08-19 09:02:56 +00:00
|
|
|
guint size, min_buffers, max_buffers;
|
2022-03-02 18:25:47 +00:00
|
|
|
GstVideoInfo info;
|
2023-06-03 15:53:40 +00:00
|
|
|
GstMemory *mem = nullptr;
|
2022-03-02 18:25:47 +00:00
|
|
|
GstCudaMemory *cmem;
|
2019-08-19 09:02:56 +00:00
|
|
|
|
|
|
|
if (!gst_buffer_pool_config_get_params (config, &caps, &size, &min_buffers,
|
2022-03-02 18:25:47 +00:00
|
|
|
&max_buffers)) {
|
|
|
|
GST_WARNING_OBJECT (self, "invalid config");
|
|
|
|
return FALSE;
|
|
|
|
}
|
2019-08-19 09:02:56 +00:00
|
|
|
|
2022-03-02 18:25:47 +00:00
|
|
|
if (!caps) {
|
|
|
|
GST_WARNING_OBJECT (pool, "no caps in config");
|
|
|
|
return FALSE;
|
|
|
|
}
|
2019-08-19 09:02:56 +00:00
|
|
|
|
2022-03-02 18:25:47 +00:00
|
|
|
if (!gst_video_info_from_caps (&info, caps)) {
|
|
|
|
GST_WARNING_OBJECT (self, "Failed to convert caps to video-info");
|
|
|
|
return FALSE;
|
|
|
|
}
|
2019-08-19 09:02:56 +00:00
|
|
|
|
2022-12-22 15:37:36 +00:00
|
|
|
if (priv->alloc) {
|
|
|
|
gst_cuda_allocator_set_active (GST_CUDA_ALLOCATOR (priv->alloc), FALSE);
|
2023-06-03 15:53:40 +00:00
|
|
|
gst_clear_object (&priv->alloc);
|
2022-12-22 15:37:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
gst_clear_cuda_stream (&priv->stream);
|
|
|
|
priv->stream = gst_buffer_pool_config_get_cuda_stream (config);
|
2023-06-03 15:53:40 +00:00
|
|
|
priv->alloc_method = gst_buffer_pool_config_get_cuda_alloc_method (config);
|
|
|
|
if (priv->alloc_method == GST_CUDA_MEMORY_ALLOC_UNKNOWN)
|
|
|
|
priv->alloc_method = GST_CUDA_MEMORY_ALLOC_MALLOC;
|
|
|
|
|
|
|
|
if (priv->alloc_method == GST_CUDA_MEMORY_ALLOC_MMAP) {
|
|
|
|
if (!gst_cuda_buffer_pool_update_alloc_prop (self)) {
|
|
|
|
GST_ERROR_OBJECT (self, "Virtual memory management is not supported");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
priv->alloc = gst_cuda_pool_allocator_new_for_virtual_memory (self->context,
|
|
|
|
priv->stream, &info, &priv->prop, CU_MEM_ALLOC_GRANULARITY_MINIMUM);
|
|
|
|
} else {
|
2024-09-10 10:29:44 +00:00
|
|
|
gboolean stream_ordered = FALSE;
|
|
|
|
if (!gst_buffer_pool_config_get_cuda_stream_ordered_alloc (config,
|
|
|
|
&stream_ordered)) {
|
|
|
|
gboolean prefer_stream_ordered = FALSE;
|
|
|
|
g_object_get (self->context, "prefer-stream-ordered-alloc",
|
|
|
|
&prefer_stream_ordered, nullptr);
|
|
|
|
if (prefer_stream_ordered) {
|
|
|
|
GST_DEBUG_OBJECT (self, "Stream ordered alloc was enabled in context");
|
|
|
|
stream_ordered = TRUE;
|
|
|
|
} else {
|
|
|
|
stream_ordered = default_stream_ordered_alloc_enabled ();
|
|
|
|
GST_DEBUG_OBJECT (self, "Use default stream ordered alloc: %d",
|
|
|
|
stream_ordered);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
GST_DEBUG_OBJECT (self,
|
|
|
|
"stream ordered alloc by config: %d", stream_ordered);
|
|
|
|
}
|
|
|
|
|
2024-08-29 11:15:20 +00:00
|
|
|
GstStructure *alloc_config = gst_structure_new ("alloc-config",
|
|
|
|
GST_CUDA_ALLOCATOR_OPT_STREAM_ORDERED, G_TYPE_BOOLEAN, stream_ordered,
|
|
|
|
nullptr);
|
|
|
|
|
|
|
|
priv->alloc = gst_cuda_pool_allocator_new_full (self->context, priv->stream,
|
|
|
|
&info, alloc_config);
|
2023-06-03 15:53:40 +00:00
|
|
|
}
|
|
|
|
|
2022-12-22 15:37:36 +00:00
|
|
|
if (!priv->alloc) {
|
|
|
|
GST_ERROR_OBJECT (self, "Couldn't create allocator");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2023-06-03 15:53:40 +00:00
|
|
|
if (!gst_cuda_allocator_set_active (GST_CUDA_ALLOCATOR (priv->alloc), TRUE)) {
|
|
|
|
GST_ERROR_OBJECT (self, "Couldn't set active");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
gst_cuda_pool_allocator_acquire_memory (priv->alloc, &mem);
|
|
|
|
gst_cuda_allocator_set_active (GST_CUDA_ALLOCATOR (priv->alloc), FALSE);
|
2022-03-02 18:25:47 +00:00
|
|
|
if (!mem) {
|
|
|
|
GST_WARNING_OBJECT (self, "Failed to allocate memory");
|
|
|
|
return FALSE;
|
2019-08-19 09:02:56 +00:00
|
|
|
}
|
|
|
|
|
2022-03-02 18:25:47 +00:00
|
|
|
cmem = GST_CUDA_MEMORY_CAST (mem);
|
2019-08-19 09:02:56 +00:00
|
|
|
|
2022-03-02 18:25:47 +00:00
|
|
|
gst_buffer_pool_config_set_params (config, caps,
|
|
|
|
GST_VIDEO_INFO_SIZE (&cmem->info), min_buffers, max_buffers);
|
2019-08-19 09:02:56 +00:00
|
|
|
|
2022-03-02 18:25:47 +00:00
|
|
|
priv->info = info;
|
2019-08-19 09:02:56 +00:00
|
|
|
|
2022-03-02 18:25:47 +00:00
|
|
|
gst_memory_unref (mem);
|
2019-08-19 09:02:56 +00:00
|
|
|
|
2022-03-02 18:25:47 +00:00
|
|
|
return GST_BUFFER_POOL_CLASS (parent_class)->set_config (pool, config);
|
2019-08-19 09:02:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static GstFlowReturn
|
|
|
|
gst_cuda_buffer_pool_alloc (GstBufferPool * pool, GstBuffer ** buffer,
|
|
|
|
GstBufferPoolAcquireParams * params)
|
|
|
|
{
|
2022-03-02 18:25:47 +00:00
|
|
|
GstCudaBufferPool *self = GST_CUDA_BUFFER_POOL_CAST (pool);
|
|
|
|
GstCudaBufferPoolPrivate *priv = self->priv;
|
|
|
|
GstVideoInfo *info = &priv->info;
|
|
|
|
GstBuffer *buf;
|
2019-08-19 09:02:56 +00:00
|
|
|
GstMemory *mem;
|
2022-03-02 18:25:47 +00:00
|
|
|
GstCudaMemory *cmem;
|
2022-12-22 15:37:36 +00:00
|
|
|
GstFlowReturn ret;
|
2019-08-19 09:02:56 +00:00
|
|
|
|
2022-12-22 15:37:36 +00:00
|
|
|
ret = gst_cuda_pool_allocator_acquire_memory (priv->alloc, &mem);
|
|
|
|
if (ret != GST_FLOW_OK) {
|
|
|
|
GST_WARNING_OBJECT (self, "Couldn't acquire memory");
|
|
|
|
return ret;
|
2019-08-19 09:02:56 +00:00
|
|
|
}
|
|
|
|
|
2022-03-02 18:25:47 +00:00
|
|
|
buf = gst_buffer_new ();
|
|
|
|
gst_buffer_append_memory (buf, mem);
|
|
|
|
|
2022-12-22 15:37:36 +00:00
|
|
|
cmem = GST_CUDA_MEMORY_CAST (mem);
|
|
|
|
|
2022-03-02 18:25:47 +00:00
|
|
|
GST_DEBUG_OBJECT (pool, "adding GstVideoMeta");
|
|
|
|
gst_buffer_add_video_meta_full (buf, GST_VIDEO_FRAME_FLAG_NONE,
|
|
|
|
GST_VIDEO_INFO_FORMAT (info), GST_VIDEO_INFO_WIDTH (info),
|
|
|
|
GST_VIDEO_INFO_HEIGHT (info), GST_VIDEO_INFO_N_PLANES (info),
|
|
|
|
cmem->info.offset, cmem->info.stride);
|
|
|
|
|
|
|
|
*buffer = buf;
|
2019-08-19 09:02:56 +00:00
|
|
|
|
|
|
|
return GST_FLOW_OK;
|
|
|
|
}
|
|
|
|
|
2022-12-22 15:37:36 +00:00
|
|
|
static gboolean
|
|
|
|
gst_cuda_buffer_pool_start (GstBufferPool * pool)
|
|
|
|
{
|
|
|
|
GstCudaBufferPool *self = GST_CUDA_BUFFER_POOL_CAST (pool);
|
|
|
|
GstCudaBufferPoolPrivate *priv = self->priv;
|
|
|
|
|
|
|
|
if (!gst_cuda_allocator_set_active (GST_CUDA_ALLOCATOR (priv->alloc), TRUE)) {
|
|
|
|
GST_ERROR_OBJECT (self, "Couldn't activate allocator");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2024-03-11 15:45:15 +00:00
|
|
|
return TRUE;
|
2022-12-22 15:37:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gst_cuda_buffer_pool_stop (GstBufferPool * pool)
|
|
|
|
{
|
|
|
|
GstCudaBufferPool *self = GST_CUDA_BUFFER_POOL_CAST (pool);
|
|
|
|
GstCudaBufferPoolPrivate *priv = self->priv;
|
|
|
|
|
|
|
|
if (priv->alloc)
|
|
|
|
gst_cuda_allocator_set_active (GST_CUDA_ALLOCATOR (priv->alloc), FALSE);
|
|
|
|
|
|
|
|
return GST_BUFFER_POOL_CLASS (parent_class)->stop (pool);
|
|
|
|
}
|
|
|
|
|
2021-12-08 11:48:08 +00:00
|
|
|
/**
|
|
|
|
* gst_cuda_buffer_pool_new:
|
|
|
|
* @context: The #GstCudaContext to use for the new buffer pool
|
|
|
|
*
|
|
|
|
* Returns: A newly created #GstCudaBufferPool
|
|
|
|
*
|
|
|
|
* Since: 1.22
|
|
|
|
*/
|
2019-08-19 09:02:56 +00:00
|
|
|
GstBufferPool *
|
|
|
|
gst_cuda_buffer_pool_new (GstCudaContext * context)
|
|
|
|
{
|
2022-03-02 18:25:47 +00:00
|
|
|
GstCudaBufferPool *self;
|
2019-08-19 09:02:56 +00:00
|
|
|
|
2023-02-05 10:50:36 +00:00
|
|
|
g_return_val_if_fail (GST_IS_CUDA_CONTEXT (context), nullptr);
|
2019-08-19 09:02:56 +00:00
|
|
|
|
2023-02-05 10:50:36 +00:00
|
|
|
self = (GstCudaBufferPool *)
|
|
|
|
g_object_new (GST_TYPE_CUDA_BUFFER_POOL, nullptr);
|
2022-03-02 18:25:47 +00:00
|
|
|
gst_object_ref_sink (self);
|
2019-08-19 09:02:56 +00:00
|
|
|
|
2023-02-05 10:50:36 +00:00
|
|
|
self->context = (GstCudaContext *) gst_object_ref (context);
|
2023-06-03 15:53:40 +00:00
|
|
|
self->priv->alloc_method = GST_CUDA_MEMORY_ALLOC_MALLOC;
|
2019-08-19 09:02:56 +00:00
|
|
|
|
2022-03-02 18:25:47 +00:00
|
|
|
return GST_BUFFER_POOL_CAST (self);
|
2019-08-19 09:02:56 +00:00
|
|
|
}
|
|
|
|
|
2022-12-22 15:37:36 +00:00
|
|
|
/**
|
|
|
|
* gst_buffer_pool_config_get_cuda_stream:
|
|
|
|
* @config: a buffer pool config
|
|
|
|
*
|
|
|
|
* Returns: (transfer full) (nullable): the currently configured #GstCudaStream
|
|
|
|
* on @config or %NULL if @config doesn't hold #GstCudaStream
|
|
|
|
*
|
|
|
|
* Since: 1.24
|
|
|
|
*/
|
|
|
|
GstCudaStream *
|
|
|
|
gst_buffer_pool_config_get_cuda_stream (GstStructure * config)
|
|
|
|
{
|
2023-02-05 10:50:36 +00:00
|
|
|
GstCudaStream *stream = nullptr;
|
2022-12-22 15:37:36 +00:00
|
|
|
|
2023-02-05 10:50:36 +00:00
|
|
|
g_return_val_if_fail (config, nullptr);
|
2022-12-22 15:37:36 +00:00
|
|
|
|
|
|
|
gst_structure_get (config, "cuda-stream", GST_TYPE_CUDA_STREAM, &stream,
|
2023-02-05 10:50:36 +00:00
|
|
|
nullptr);
|
2022-12-22 15:37:36 +00:00
|
|
|
|
|
|
|
return stream;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_buffer_pool_config_set_cuda_stream:
|
|
|
|
* @config: a buffer pool config
|
|
|
|
* @stream: a #GstCudaStream
|
|
|
|
*
|
|
|
|
* Sets @stream on @config
|
|
|
|
*
|
|
|
|
* Since: 1.24
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gst_buffer_pool_config_set_cuda_stream (GstStructure * config,
|
|
|
|
GstCudaStream * stream)
|
|
|
|
{
|
|
|
|
g_return_if_fail (config);
|
|
|
|
g_return_if_fail (GST_IS_CUDA_STREAM (stream));
|
|
|
|
|
2023-02-05 10:50:36 +00:00
|
|
|
gst_structure_set (config,
|
|
|
|
"cuda-stream", GST_TYPE_CUDA_STREAM, stream, nullptr);
|
2022-12-22 15:37:36 +00:00
|
|
|
}
|
|
|
|
|
2023-06-03 15:53:40 +00:00
|
|
|
/**
|
|
|
|
* gst_buffer_pool_config_get_cuda_alloc_method:
|
|
|
|
* @config: a buffer pool config
|
|
|
|
*
|
|
|
|
* Gets configured allocation method
|
|
|
|
*
|
|
|
|
* Since: 1.24
|
|
|
|
*/
|
|
|
|
GstCudaMemoryAllocMethod
|
|
|
|
gst_buffer_pool_config_get_cuda_alloc_method (GstStructure * config)
|
|
|
|
{
|
|
|
|
GstCudaMemoryAllocMethod type;
|
|
|
|
|
|
|
|
g_return_val_if_fail (config, GST_CUDA_MEMORY_ALLOC_UNKNOWN);
|
|
|
|
|
|
|
|
if (gst_structure_get_enum (config, "cuda-alloc-method",
|
|
|
|
GST_TYPE_CUDA_MEMORY_ALLOC_METHOD, (gint *) & type)) {
|
|
|
|
return type;
|
|
|
|
}
|
|
|
|
|
|
|
|
return GST_CUDA_MEMORY_ALLOC_UNKNOWN;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_buffer_pool_config_set_cuda_alloc_method:
|
|
|
|
* @config: a buffer pool config
|
|
|
|
*
|
|
|
|
* Sets allocation method
|
|
|
|
*
|
|
|
|
* Since: 1.24
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gst_buffer_pool_config_set_cuda_alloc_method (GstStructure * config,
|
|
|
|
GstCudaMemoryAllocMethod method)
|
|
|
|
{
|
|
|
|
g_return_if_fail (config);
|
|
|
|
|
|
|
|
gst_structure_set (config, "cuda-alloc-method",
|
|
|
|
GST_TYPE_CUDA_MEMORY_ALLOC_METHOD, method, nullptr);
|
|
|
|
}
|
|
|
|
|
2024-08-29 11:15:20 +00:00
|
|
|
/**
|
|
|
|
* gst_buffer_pool_config_get_cuda_stream_ordered_alloc:
|
|
|
|
* @config: a buffer pool config
|
2024-09-10 10:29:44 +00:00
|
|
|
* @enabled: (out): whether stream ordered allocation was requested or not
|
2024-08-29 11:15:20 +00:00
|
|
|
*
|
2024-09-10 10:29:44 +00:00
|
|
|
* Returns: %TRUE stream ordered allocation option was specified
|
2024-08-29 11:15:20 +00:00
|
|
|
*
|
|
|
|
* Since: 1.26
|
|
|
|
*/
|
|
|
|
gboolean
|
2024-09-10 10:29:44 +00:00
|
|
|
gst_buffer_pool_config_get_cuda_stream_ordered_alloc (GstStructure * config,
|
|
|
|
gboolean * enabled)
|
2024-08-29 11:15:20 +00:00
|
|
|
{
|
|
|
|
gboolean stream_ordered = FALSE;
|
|
|
|
|
|
|
|
g_return_val_if_fail (config, FALSE);
|
|
|
|
|
|
|
|
if (!gst_structure_get_boolean (config,
|
|
|
|
"cuda-stream-ordered-alloc", &stream_ordered)) {
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2024-09-10 10:29:44 +00:00
|
|
|
if (enabled)
|
|
|
|
*enabled = stream_ordered;
|
|
|
|
|
|
|
|
return TRUE;
|
2024-08-29 11:15:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_buffer_pool_config_set_cuda_stream_ordered_alloc:
|
|
|
|
* @config: a buffer pool config
|
|
|
|
* @stream_ordered: whether stream ordered allocation is allowed
|
|
|
|
*
|
|
|
|
* Sets stream ordered allocation option
|
|
|
|
*
|
|
|
|
* Since: 1.26
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gst_buffer_pool_config_set_cuda_stream_ordered_alloc (GstStructure * config,
|
|
|
|
gboolean stream_ordered)
|
|
|
|
{
|
|
|
|
g_return_if_fail (config);
|
|
|
|
|
|
|
|
gst_structure_set (config, "cuda-stream-ordered-alloc", G_TYPE_BOOLEAN,
|
|
|
|
stream_ordered, nullptr);
|
|
|
|
}
|
|
|
|
|
2019-08-19 09:02:56 +00:00
|
|
|
static void
|
|
|
|
gst_cuda_buffer_pool_dispose (GObject * object)
|
|
|
|
{
|
2022-03-02 18:25:47 +00:00
|
|
|
GstCudaBufferPool *self = GST_CUDA_BUFFER_POOL_CAST (object);
|
2022-12-22 15:37:36 +00:00
|
|
|
GstCudaBufferPoolPrivate *priv = self->priv;
|
|
|
|
|
|
|
|
if (priv->alloc) {
|
|
|
|
gst_cuda_allocator_set_active (GST_CUDA_ALLOCATOR (priv->alloc), FALSE);
|
|
|
|
gst_clear_object (&priv->alloc);
|
|
|
|
}
|
2019-08-19 09:02:56 +00:00
|
|
|
|
2022-12-22 15:37:36 +00:00
|
|
|
gst_clear_cuda_stream (&priv->stream);
|
2022-03-02 18:25:47 +00:00
|
|
|
gst_clear_object (&self->context);
|
2019-08-19 09:02:56 +00:00
|
|
|
|
|
|
|
G_OBJECT_CLASS (parent_class)->dispose (object);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_cuda_buffer_pool_class_init (GstCudaBufferPoolClass * klass)
|
|
|
|
{
|
|
|
|
GObjectClass *gobject_class = (GObjectClass *) klass;
|
2022-03-02 18:25:47 +00:00
|
|
|
GstBufferPoolClass *bufferpool_class = (GstBufferPoolClass *) klass;
|
2019-08-19 09:02:56 +00:00
|
|
|
|
|
|
|
gobject_class->dispose = gst_cuda_buffer_pool_dispose;
|
|
|
|
|
2022-03-02 18:25:47 +00:00
|
|
|
bufferpool_class->get_options = gst_cuda_buffer_pool_get_options;
|
|
|
|
bufferpool_class->set_config = gst_cuda_buffer_pool_set_config;
|
2022-12-22 15:37:36 +00:00
|
|
|
bufferpool_class->start = gst_cuda_buffer_pool_start;
|
|
|
|
bufferpool_class->stop = gst_cuda_buffer_pool_stop;
|
2022-03-02 18:25:47 +00:00
|
|
|
bufferpool_class->alloc_buffer = gst_cuda_buffer_pool_alloc;
|
2019-08-19 09:02:56 +00:00
|
|
|
|
|
|
|
GST_DEBUG_CATEGORY_INIT (gst_cuda_buffer_pool_debug, "cudabufferpool", 0,
|
|
|
|
"CUDA Buffer Pool");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_cuda_buffer_pool_init (GstCudaBufferPool * pool)
|
|
|
|
{
|
2023-02-05 10:50:36 +00:00
|
|
|
pool->priv = (GstCudaBufferPoolPrivate *)
|
|
|
|
gst_cuda_buffer_pool_get_instance_private (pool);
|
2019-08-19 09:02:56 +00:00
|
|
|
}
|