d3d11memory, d3d12memory: Fix outstanding memory count tracing

Gets being released memory back to queue even if allocator is flushing
in order to count the number of outstanding memory objects.
Also, clear queue if there's no outstanding memory object and
allocator is flushing

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6240>
This commit is contained in:
Seungha Yang 2024-02-29 02:41:42 +09:00 committed by GStreamer Marge Bot
parent 27d5e269cc
commit d0713e029c
3 changed files with 5 additions and 16 deletions

View file

@ -243,9 +243,9 @@ gst_d3d11_buffer_pool_set_config (GstBufferPool * pool, GstStructure * config)
pool_alloc = GST_D3D11_POOL_ALLOCATOR (alloc);
flow_ret = gst_d3d11_pool_allocator_acquire_memory (pool_alloc, &mem);
gst_d3d11_allocator_set_active (alloc, FALSE);
if (flow_ret != GST_FLOW_OK) {
GST_ERROR_OBJECT (self, "Failed to allocate initial memory");
gst_d3d11_allocator_set_active (alloc, FALSE);
gst_object_unref (alloc);
return FALSE;
}
@ -254,7 +254,6 @@ gst_d3d11_buffer_pool_set_config (GstBufferPool * pool, GstStructure * config)
&stride) || stride < desc[i].Width) {
GST_ERROR_OBJECT (self, "Failed to calculate stride");
gst_d3d11_allocator_set_active (alloc, FALSE);
gst_object_unref (alloc);
gst_memory_unref (mem);

View file

@ -2208,6 +2208,8 @@ gst_d3d11_pool_allocator_release_memory (GstD3D11PoolAllocator * self,
/* keep it around in our queue */
priv->queue.push (mem);
priv->outstanding--;
if (priv->outstanding == 0 && priv->flushing)
gst_d3d11_pool_allocator_stop (self);
WakeAllConditionVariable (&priv->cond);
ReleaseSRWLockExclusive (&priv->lock);
@ -2232,13 +2234,6 @@ gst_d3d11_memory_release (GstMiniObject * object)
priv = alloc->priv;
AcquireSRWLockExclusive (&priv->lock);
/* if flushing, free this memory */
if (alloc->priv->flushing) {
ReleaseSRWLockExclusive (&priv->lock);
GST_LOG_OBJECT (alloc, "allocator is flushing, free %p", mem);
return TRUE;
}
/* return the memory to the allocator */
gst_memory_ref (mem);
gst_d3d11_pool_allocator_release_memory (alloc, mem);

View file

@ -1100,6 +1100,8 @@ gst_d3d12_pool_allocator_release_memory (GstD3D12PoolAllocator * self,
/* keep it around in our queue */
priv->queue.push (mem);
priv->outstanding--;
if (priv->outstanding == 0 && priv->flushing)
gst_d3d12_pool_allocator_stop (self);
priv->cond.notify_all ();
priv->lock.unlock ();
@ -1124,13 +1126,6 @@ gst_d3d12_memory_release (GstMiniObject * mini_object)
priv = alloc->priv;
priv->lock.lock ();
/* if flushing, free this memory */
if (alloc->priv->flushing) {
priv->lock.unlock ();
GST_LOG_OBJECT (alloc, "allocator is flushing, free %p", mem);
return TRUE;
}
/* return the memory to the allocator */
gst_memory_ref (mem);
gst_d3d12_pool_allocator_release_memory (alloc, mem);