From 9a53d798765b54ff8e9e5acb25b13d4a3bc22edf Mon Sep 17 00:00:00 2001 From: George Kiagiadakis Date: Mon, 7 Dec 2015 14:31:40 +0100 Subject: [PATCH] ahcsrc: fix deadlock when flushing _data_queue_item_free() calls gst_buffer_unref(), which calls gst_ahc_src_buffer_free_func(), which calls g_mutex_lock() on self->mutex and there you go... deadlock! --- sys/androidmedia/gstahcsrc.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/sys/androidmedia/gstahcsrc.c b/sys/androidmedia/gstahcsrc.c index d67ea03aea..127060036a 100644 --- a/sys/androidmedia/gstahcsrc.c +++ b/sys/androidmedia/gstahcsrc.c @@ -2255,7 +2255,7 @@ gst_ahc_src_on_preview_frame (jbyteArray array, gpointer user_data) GstClockTime timestamp = GST_CLOCK_TIME_NONE; GstClockTime duration = 0; GstClock *clock; - + gboolean queued = FALSE; g_mutex_lock (&self->mutex); @@ -2315,14 +2315,16 @@ gst_ahc_src_on_preview_frame (jbyteArray array, gpointer user_data) GST_DEBUG_OBJECT (self, "wrapping jni array %p->%p %p->%p", item, item->object, malloc_data, malloc_data->array); - if (!gst_data_queue_push (self->queue, item)) { - GST_INFO_OBJECT (self, "can't add buffer to queue"); - /* Can't add buffer to queue. Must be flushing. */ - _data_queue_item_free (item); - } + queued = gst_data_queue_push (self->queue, item); done: g_mutex_unlock (&self->mutex); + + if (item && !queued) { + GST_INFO_OBJECT (self, "could not add buffer to queue"); + /* Can't add buffer to queue. Must be flushing. */ + _data_queue_item_free (item); + } } static void