From e96b8a7b5fce65f223360058f16bfa75b7d55030 Mon Sep 17 00:00:00 2001 From: Lasse Laukkanen Date: Thu, 2 Dec 2010 05:39:14 -0300 Subject: [PATCH] camerabin: Avoid assertion on image finishing As imgbin_finished() is scheduled from g_idle_add, it might be run a little later than expected, this can lead to the application setting camerabin to ready before imgbin_finished() runs. In this case, the processing counter goes to 0 and an assertion happens. This patch relaxes the imgbin_finished() check on the processing counter. --- gst/camerabin/gstcamerabin.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/gst/camerabin/gstcamerabin.c b/gst/camerabin/gstcamerabin.c index 7375402553..3645daf65e 100644 --- a/gst/camerabin/gstcamerabin.c +++ b/gst/camerabin/gstcamerabin.c @@ -3923,7 +3923,17 @@ gst_camerabin_imgbin_finished (gpointer u_data) /* Close the file of saved image */ gst_element_set_state (camera->imgbin, GST_STATE_READY); GST_DEBUG_OBJECT (camera, "Image pipeline set to READY"); - CAMERABIN_PROCESSING_DEC (camera); + + g_mutex_lock (camera->capture_mutex); + if (camera->processing_counter) { + CAMERABIN_PROCESSING_DEC_UNLOCKED (camera); + } else { + /* Camerabin state change to READY may have reset processing counter to + * zero. This is possible as this functions is scheduled from g_idle_add + */ + GST_WARNING_OBJECT (camera, "camerabin has been forced to idle"); + } + g_mutex_unlock (camera->capture_mutex); /* Send image-done signal */ gst_camerabin_image_capture_continue (camera, filename);