camerabin: Make sure video-done is post only when file is closed
authorThiago Santos <ts.santos@partner.samsung.com>
Thu, 7 Nov 2013 01:13:13 +0000 (22:13 -0300)
committerThiago Santos <ts.santos@partner.samsung.com>
Thu, 7 Nov 2013 01:13:54 +0000 (22:13 -0300)
Force filesink to null before posting video-done to make sure the
file was closed.

Had to do it from a separate thread to avoid calling state_change from
a sync message handler.

https://bugzilla.gnome.org/show_bug.cgi?id=709373

gst/camerabin2/gstcamerabin2.c

index 829ab0d..f64ce2b 100644 (file)
@@ -955,6 +955,16 @@ gst_camera_bin_skip_next_preview (GstCameraBin2 * camerabin)
   g_mutex_unlock (&camerabin->preview_list_mutex);
 }
 
+static void
+gst_camera_bin_finish_video_file (GstCameraBin2 * camerabin)
+{
+  /* make sure the file is closed */
+  gst_element_set_state (camerabin->videosink, GST_STATE_NULL);
+
+  gst_video_capture_bin_post_video_done (camerabin);
+  GST_CAMERA_BIN2_PROCESSING_DEC (camerabin);
+}
+
 static gpointer
 gst_camera_bin_video_reset_elements (gpointer u_data)
 {
@@ -963,6 +973,8 @@ gst_camera_bin_video_reset_elements (gpointer u_data)
   GST_DEBUG_OBJECT (camerabin, "Resetting video elements state");
   g_mutex_lock (&camerabin->video_capture_mutex);
 
+  gst_camera_bin_finish_video_file (camerabin);
+
   /* reset element states to clear eos/flushing pads */
   gst_element_set_state (camerabin->video_encodebin, GST_STATE_READY);
   gst_element_set_state (camerabin->videobin_capsfilter, GST_STATE_READY);
@@ -1082,9 +1094,6 @@ gst_camera_bin_handle_message (GstBin * bin, GstMessage * message)
         GST_DEBUG_OBJECT (bin, "EOS from video branch");
         g_assert (camerabin->video_state == GST_CAMERA_BIN_VIDEO_FINISHING);
 
-        gst_video_capture_bin_post_video_done (GST_CAMERA_BIN2_CAST (bin));
-        dec_counter = TRUE;
-
         if (!g_thread_try_new ("reset-element-thread",
                 gst_camera_bin_video_reset_elements, gst_object_ref (camerabin),
                 NULL)) {