v4l2videodec: Handle flush while in start_streaming
authorNicolas Dufresne <nicolas.dufresne@collabora.com>
Fri, 16 May 2014 21:46:30 +0000 (17:46 -0400)
committerNicolas Dufresne <nicolas.dufresne@collabora.co.uk>
Sat, 17 May 2014 01:49:00 +0000 (21:49 -0400)
We need to handle the case where a flush occure while the streaming
thread is being brought up. In this case, the flushing state of the poll
object is cleared. To solve this, we simply set the capture poll to flushing
again, this way we know the thread will exit. The decoder streamlock
is used to synchronize with handle frame.

sys/v4l2/gstv4l2videodec.c

index c2584f9..1b4a051 100644 (file)
@@ -263,8 +263,10 @@ gst_v4l2_video_dec_flush (GstVideoDecoder * decoder)
 
   /* Wait for capture thread to stop */
   GST_VIDEO_DECODER_STREAM_UNLOCK (decoder);
+  gst_v4l2_object_unlock (self->v4l2capture);
   gst_pad_stop_task (decoder->srcpad);
   GST_VIDEO_DECODER_STREAM_LOCK (decoder);
+
   self->output_flow = GST_FLOW_OK;
 
   if (self->v4l2output->pool)
@@ -309,7 +311,7 @@ gst_v4l2_video_dec_finish (GstVideoDecoder * decoder)
   GST_VIDEO_DECODER_STREAM_LOCK (decoder);
 
   /* Ensure the processing thread has stopped */
-  if (self->processing) {
+  if (g_atomic_int_get (&self->processing)) {
     gst_v4l2_object_unlock (self->v4l2capture);
     gst_pad_stop_task (decoder->srcpad);
     g_assert (g_atomic_int_get (&self->processing) == FALSE);