mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-05-15 04:38:56 +00:00
libs: videopool: fix undocumented behavior and counting
gst_vaapi_video_pool_reserve_unlocked() hit an undocumented behavoir because it locks twice the same mutex. Also, n had different meanings in the current code: as an increase value and as a new total of allocated surfaces. This patche removes the undocumented behavoir (usually a deadlock) and fixes the meaning of n as the new total of allocated surfaces. Signed-off-by: Víctor Manuel Jáquez Leal <vjaquez@igalia.com>
This commit is contained in:
parent
5939bf4d81
commit
e96a435756
1 changed files with 15 additions and 17 deletions
|
@ -328,30 +328,16 @@ gst_vaapi_video_pool_get_size (GstVaapiVideoPool * pool)
|
|||
return size;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_vaapi_video_pool_reserve:
|
||||
* @pool: a #GstVaapiVideoPool
|
||||
* @n: the number of objects to pre-allocate
|
||||
*
|
||||
* Pre-allocates up to @n objects in the pool. If @n is less than or
|
||||
* equal to the number of free and used objects in the pool, this call
|
||||
* has no effect. Otherwise, it is a request for allocation of
|
||||
* additional objects.
|
||||
*
|
||||
* Return value: %TRUE on success
|
||||
*/
|
||||
static gboolean
|
||||
gst_vaapi_video_pool_reserve_unlocked (GstVaapiVideoPool * pool, guint n)
|
||||
{
|
||||
guint i, num_allocated;
|
||||
|
||||
num_allocated = gst_vaapi_video_pool_get_size (pool) + pool->used_count;
|
||||
if (n < num_allocated)
|
||||
num_allocated = g_queue_get_length (&pool->free_objects) + pool->used_count;
|
||||
if (n <= num_allocated)
|
||||
return TRUE;
|
||||
|
||||
if ((n -= num_allocated) > pool->capacity)
|
||||
n = pool->capacity;
|
||||
|
||||
n = MIN (n, pool->capacity);
|
||||
for (i = num_allocated; i < n; i++) {
|
||||
gpointer object;
|
||||
|
||||
|
@ -365,6 +351,18 @@ gst_vaapi_video_pool_reserve_unlocked (GstVaapiVideoPool * pool, guint n)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_vaapi_video_pool_reserve:
|
||||
* @pool: a #GstVaapiVideoPool
|
||||
* @n: the number of objects to pre-allocate
|
||||
*
|
||||
* Pre-allocates up to @n objects in the pool. If @n is less than or
|
||||
* equal to the number of free and used objects in the pool, this call
|
||||
* has no effect. Otherwise, it is a request for allocation of
|
||||
* additional objects.
|
||||
*
|
||||
* Return value: %TRUE on success
|
||||
*/
|
||||
gboolean
|
||||
gst_vaapi_video_pool_reserve (GstVaapiVideoPool * pool, guint n)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue