v4l2: Move capture eos handling in _process()

Now that we might be copying out buffer (e.g. downstream don't support video
meta bug we need it) we need to move the EOS handling inside the process
method.
This commit is contained in:
Nicolas Dufresne 2014-03-25 15:21:03 -04:00
parent 49065b1693
commit 8d6e72a299
2 changed files with 18 additions and 7 deletions

View file

@ -1441,14 +1441,24 @@ gst_v4l2_buffer_pool_process (GstV4l2BufferPool * pool, GstBuffer * buf)
{
GstBuffer *tmp;
if (buf->pool == bpool)
/* nothing, data was inside the buffer when we did _acquire() */
goto done;
if (buf->pool == bpool) {
if (gst_buffer_get_size (buf) == 0)
goto eos;
else
/* nothing, data was inside the buffer when we did _acquire() */
goto done;
}
/* buffer not from our pool, grab a frame and copy it into the target */
if ((ret = gst_v4l2_buffer_pool_dqbuf (pool, &tmp)) != GST_FLOW_OK)
goto done;
/* An empty buffer on capture indicates the end of stream */
if (gst_buffer_get_size (tmp) == 0) {
gst_buffer_unref (tmp);
goto eos;
}
if (!gst_v4l2_object_copy (obj, buf, tmp))
goto copy_failed;
@ -1556,6 +1566,11 @@ start_failed:
GST_ERROR_OBJECT (obj->element, "failed to start streaming");
return GST_FLOW_ERROR;
}
eos:
{
GST_DEBUG_OBJECT (obj->element, "end of stream reached");
return GST_FLOW_EOS;
}
}

View file

@ -393,10 +393,6 @@ gst_v4l2_video_dec_loop (GstVideoDecoder * decoder)
if (ret != GST_FLOW_OK)
goto beach;
/* Check if buffer isn't the last one */
if (gst_buffer_get_size (buffer) == 0)
goto beach;
GST_LOG_OBJECT (decoder, "Process output buffer");
ret =
gst_v4l2_buffer_pool_process (GST_V4L2_BUFFER_POOL (self->