v4l2videodec: handle stop being called without flush
authorNicolas Dufresne <nicolas.dufresne@collabora.com>
Wed, 12 Mar 2014 16:11:16 +0000 (17:11 +0100)
committerNicolas Dufresne <nicolas.dufresne@collabora.com>
Thu, 8 May 2014 19:56:35 +0000 (15:56 -0400)
Uppon certain downstream error, stop() is called without a flush(). This mean that
the streaming thread may still be running even though unlock has been called.
Now calling flush to reset the decoder state if we are processing.

sys/v4l2/gstv4l2videodec.c

index dc79161..2fc2763 100644 (file)
@@ -210,6 +210,15 @@ gst_v4l2_video_dec_stop (GstVideoDecoder * decoder)
 
   GST_DEBUG_OBJECT (self, "Stopping");
 
+  gst_v4l2_object_unlock (self->v4l2output);
+  gst_v4l2_object_unlock (self->v4l2capture);
+
+  GST_VIDEO_DECODER_STREAM_LOCK (decoder);
+  /* Wait for capture thread to stop */
+  gst_pad_stop_task (decoder->srcpad);
+  self->output_flow = GST_FLOW_OK;
+  GST_VIDEO_DECODER_STREAM_UNLOCK (decoder);
+
   /* Should have been flushed already */
   g_assert (g_atomic_int_get (&self->active) == FALSE);
   g_assert (g_atomic_int_get (&self->processing) == FALSE);