v4l2bufferpool: Validate stride/offset when importing

This will prevent situation where buffer size allow importing but rendering
goes wrong due to a miss-match in expected stride and offset.

https://bugzilla.gnome.org/show_bug.cgi?id=583890
This commit is contained in:
Nicolas Dufresne 2018-07-25 19:27:01 -04:00
parent 1c729be537
commit 480a7bcab8

View file

@ -742,10 +742,23 @@ gst_v4l2_buffer_pool_start (GstBufferPool * bpool)
GST_DEBUG_OBJECT (pool, "activating pool");
if (pool->other_pool)
if (pool->other_pool) {
GstBuffer *buffer;
if (!gst_buffer_pool_set_active (pool->other_pool, TRUE))
goto other_pool_failed;
if (gst_buffer_pool_acquire_buffer (pool->other_pool, &buffer, NULL) !=
GST_FLOW_OK)
goto other_pool_failed;
if (!gst_v4l2_object_try_import (obj, buffer)) {
gst_buffer_unref (buffer);
goto cannot_import;
}
gst_buffer_unref (buffer);
}
config = gst_buffer_pool_get_config (bpool);
if (!gst_buffer_pool_config_get_params (config, &caps, &size, &min_buffers,
&max_buffers))
@ -912,6 +925,11 @@ queue_failed:
GST_ERROR_OBJECT (pool, "failed to queue buffers into the capture queue");
return FALSE;
}
cannot_import:
{
GST_ERROR_OBJECT (pool, "cannot import buffers from downstream pool");
return FALSE;
}
}
static gboolean