videopool: Release lock while allocating new object

The video pool can be accessed with the display lock held, for example,
when releasing a buffer from inside vaapisink_render, but allocating
a new object can may also take the display lock. Which means a possible
deadlock.

https://bugzilla.gnome.org/show_bug.cgi?id=747944
This commit is contained in:
Olivier Crete 2015-04-15 15:20:17 -04:00 committed by Víctor Manuel Jáquez Leal
parent 504fdedf84
commit 0adb36b658

View file

@ -177,7 +177,9 @@ gst_vaapi_video_pool_get_object_unlocked (GstVaapiVideoPool * pool)
object = g_queue_pop_head (&pool->free_objects);
if (!object) {
g_mutex_unlock (&pool->mutex);
object = gst_vaapi_video_pool_alloc_object (pool);
g_mutex_lock (&pool->mutex);
if (!object)
return NULL;
}
@ -354,7 +356,11 @@ gst_vaapi_video_pool_reserve_unlocked (GstVaapiVideoPool * pool, guint n)
n = pool->capacity;
for (i = num_allocated; i < n; i++) {
gpointer const object = gst_vaapi_video_pool_alloc_object (pool);
gpointer object;
g_mutex_unlock (&pool->mutex);
object = gst_vaapi_video_pool_alloc_object (pool);
g_mutex_lock (&pool->mutex);
if (!object)
return FALSE;
g_queue_push_tail (&pool->free_objects, object);