This allow calling start streaming later for capture device. Currently it breaks
in dmabuf-import because downstream is holding a buffer that will only be
released after stream-start.
https://bugzilla.gnome.org/show_bug.cgi?id=730207
/**
- * gst_v4l2_buffer_pool_flush:
+ * gst_v4l2_buffer_pool_stop_streaming:
* @bpool: a #GstBufferPool
*
* First, set obj->poll to be flushing
* Call STREAMOFF to clear QUEUED flag on every driver buffers.
* Then release all buffers that are in pool->buffers array.
- * Finally call STREAMON if CAPTURE type
- * The caller is responsible to unset flushing on obj->pool
*
* Returns: TRUE on success.
*/
gboolean
-gst_v4l2_buffer_pool_flush (GstV4l2BufferPool * pool)
+gst_v4l2_buffer_pool_stop_streaming (GstV4l2BufferPool * pool)
{
- GstV4l2Object *obj = pool->obj;
+ GST_DEBUG_OBJECT (pool, "stop streaming");
- GST_DEBUG_OBJECT (pool, "flush");
+ if (!stop_streaming (pool))
+ goto stop_failed;
- stop_streaming (pool);
+ return TRUE;
- /* we can start capturing now, we wait for the playback
- * case until we queued the first buffer */
- if (!V4L2_TYPE_IS_OUTPUT (obj->type))
- if (!start_streaming (pool))
- goto start_failed;
+ /* ERRORS */
+stop_failed:
+ {
+ GST_ERROR_OBJECT (pool, "failed to stop streaming");
+ return FALSE;
+ }
+}
+
+gboolean
+gst_v4l2_buffer_pool_start_streaming (GstV4l2BufferPool * pool)
+{
+ GST_DEBUG_OBJECT (pool, "start straming");
+
+ if (!start_streaming (pool))
+ goto start_failed;
return TRUE;
GstFlowReturn gst_v4l2_buffer_pool_process (GstV4l2BufferPool * bpool, GstBuffer ** buf);
-gboolean gst_v4l2_buffer_pool_flush (GstV4l2BufferPool * pool);
+gboolean gst_v4l2_buffer_pool_stop_streaming (GstV4l2BufferPool * pool);
+gboolean gst_v4l2_buffer_pool_start_streaming (GstV4l2BufferPool * pool);
void gst_v4l2_buffer_pool_set_other_pool (GstV4l2BufferPool * pool,
GstBufferPool * other_pool);
gst_v4l2_transform_sink_event (GstBaseTransform * trans, GstEvent * event)
{
GstV4l2Transform *self = GST_V4L2_TRANSFORM (trans);
+ gboolean ret;
+
+ /* Nothing to flush in passthrough */
+ if (gst_base_transform_is_passthrough (trans))
+ return GST_BASE_TRANSFORM_CLASS (parent_class)->sink_event (trans, event);
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_FLUSH_START:
break;
case GST_EVENT_FLUSH_STOP:
GST_DEBUG_OBJECT (self, "flush stop");
- if (self->v4l2output->pool)
- gst_v4l2_buffer_pool_flush (GST_V4L2_BUFFER_POOL (self->v4l2output->
- pool));
+
+ if (self->v4l2output->pool) {
+ gst_v4l2_buffer_pool_stop_streaming (GST_V4L2_BUFFER_POOL
+ (self->v4l2output->pool));
+ gst_v4l2_buffer_pool_start_streaming (GST_V4L2_BUFFER_POOL
+ (self->v4l2capture->pool));
+ gst_v4l2_object_unlock_stop (self->v4l2output);
+ }
if (self->v4l2capture->pool)
- gst_v4l2_buffer_pool_flush (GST_V4L2_BUFFER_POOL (self->v4l2capture->
- pool));
- gst_v4l2_object_unlock_stop (self->v4l2output);
- gst_v4l2_object_unlock_stop (self->v4l2capture);
+ gst_v4l2_buffer_pool_stop_streaming (GST_V4L2_BUFFER_POOL
+ (self->v4l2capture->pool));
default:
break;
}
- return GST_BASE_TRANSFORM_CLASS (parent_class)->sink_event (trans, event);
+ ret = GST_BASE_TRANSFORM_CLASS (parent_class)->sink_event (trans, event);
+
+ switch (GST_EVENT_TYPE (event)) {
+ case GST_EVENT_FLUSH_STOP:
+ /* Buffer should be back now */
+ if (self->v4l2capture->pool) {
+ gst_v4l2_buffer_pool_start_streaming (GST_V4L2_BUFFER_POOL
+ (self->v4l2capture->pool));
+ gst_v4l2_object_unlock_stop (self->v4l2capture);
+ }
+ GST_DEBUG_OBJECT (self, "flush stop done");
+ break;
+ default:
+ break;
+ }
+
+ return ret;
}
static GstStateChangeReturn
self->output_flow = GST_FLOW_OK;
if (self->v4l2output->pool)
- gst_v4l2_buffer_pool_flush (GST_V4L2_BUFFER_POOL (self->v4l2output->pool));
+ gst_v4l2_buffer_pool_stop_streaming (GST_V4L2_BUFFER_POOL
+ (self->v4l2output->pool));
if (self->v4l2capture->pool)
- gst_v4l2_buffer_pool_flush (GST_V4L2_BUFFER_POOL (self->v4l2capture->pool));
-
- /* Output will remain flushing until new frame comes in */
- gst_v4l2_object_unlock_stop (self->v4l2capture);
+ gst_v4l2_buffer_pool_stop_streaming (GST_V4L2_BUFFER_POOL
+ (self->v4l2capture->pool));
return TRUE;
}
GST_DEBUG_OBJECT (self, "Starting decoding thread");
/* Enable processing input */
+ gst_v4l2_buffer_pool_start_streaming (GST_V4L2_BUFFER_POOL
+ (self->v4l2capture->pool));
gst_v4l2_object_unlock_stop (self->v4l2output);
+ gst_v4l2_object_unlock_stop (self->v4l2capture);
/* Start the processing task, when it quits, the task will disable input
* processing to unlock input if draining, or prevent potential block */