v4l2videodec: Handle early task stop
authorNicolas Dufresne <nicolas.dufresne@collabora.com>
Fri, 23 May 2014 21:54:20 +0000 (17:54 -0400)
committerNicolas Dufresne <nicolas.dufresne@collabora.co.uk>
Sat, 24 May 2014 19:38:53 +0000 (15:38 -0400)
sys/v4l2/gstv4l2videodec.c

index 3d793e9..cc730e1 100644 (file)
@@ -418,6 +418,20 @@ beach:
   gst_pad_pause_task (decoder->srcpad);
 }
 
+static void
+gst_v4l2_video_dec_loop_stopped (GstV4l2VideoDec * self)
+{
+  /* When flushing, decoding thread may never run */
+  if (g_atomic_int_get (&self->processing)) {
+    GST_DEBUG_OBJECT (self, "Early stop of decoding thread");
+    self->output_flow = GST_FLOW_FLUSHING;
+    g_atomic_int_set (&self->processing, FALSE);
+  }
+
+  GST_DEBUG_OBJECT (self, "Decoding task destroyed: %s",
+      gst_flow_get_name (self->output_flow));
+}
+
 static GstFlowReturn
 gst_v4l2_video_dec_handle_frame (GstVideoDecoder * decoder,
     GstVideoCodecFrame * frame)
@@ -517,7 +531,8 @@ gst_v4l2_video_dec_handle_frame (GstVideoDecoder * decoder,
      * processing to unlock input if draining, or prevent potential block */
     g_atomic_int_set (&self->processing, TRUE);
     if (!gst_pad_start_task (decoder->srcpad,
-            (GstTaskFunction) gst_v4l2_video_dec_loop, self, NULL))
+            (GstTaskFunction) gst_v4l2_video_dec_loop, self,
+            (GDestroyNotify) gst_v4l2_video_dec_loop_stopped))
       goto start_task_failed;
   }