From d946e7972e0d361f2060349440f0b879c458f59b Mon Sep 17 00:00:00 2001 From: Simon Farnsworth Date: Mon, 29 Jun 2015 13:06:30 +0300 Subject: [PATCH] Work around ABBA deadlock between vaapisink and vaapipostproc vaapisink takes the display lock, then does a gst_buffer_replace which can take the lock on the gst_vaapi_video_pool. vaapipostproc asks the gst_vaapi_video_pool for a new surface. This takes the lock on the gst_vaapi_video_pool; if you're unlucky, there are no free surfaces, which means that gst_vaapi_surface_create is called. gst_vaapi_surface_create takes the display lock. If vaapisink and vaapipostproc are in different threads, and this happens, you get a deadlock. vaapisink holds the display lock, and wants the gst_vaapi_video_pool lock. vaapipostproc holds the gst_vaapi_video_pool lock and wants the display lock. Work around this by releasing the display lock in vaapisink around the gst_buffer_replace. https://bugzilla.gnome.org/show_bug.cgi?id=738249 Signed-off-by: Simon Farnsworth Signed-off-by: Sreerenj Balachandran --- gst/vaapi/gstvaapisink.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gst/vaapi/gstvaapisink.c b/gst/vaapi/gstvaapisink.c index 82769684e6..2fa36668b0 100644 --- a/gst/vaapi/gstvaapisink.c +++ b/gst/vaapi/gstvaapisink.c @@ -1403,7 +1403,10 @@ gst_vaapisink_show_frame_unlocked (GstVaapiSink * sink, GstBuffer * src_buffer) g_signal_emit (sink, gst_vaapisink_signals[HANDOFF_SIGNAL], 0, buffer); /* Retain VA surface until the next one is displayed */ + /* Need to release the lock for the duration, otherwise a deadlock is possible */ + gst_vaapi_display_unlock (GST_VAAPI_PLUGIN_BASE_DISPLAY (sink)); gst_buffer_replace (&sink->video_buffer, buffer); + gst_vaapi_display_lock (GST_VAAPI_PLUGIN_BASE_DISPLAY (sink)); ret = GST_FLOW_OK;