mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-25 01:30:38 +00:00
v4l2bufferpool: Improve buffer validation
Improve buffer validation by making sure each memory are the right one and that each memory is writable. This fixes tearing issues in case downstream uses gst_buffer_make_writable() or other type of GstBuffer copy where memory are only reffed. https://bugzilla.gnome.org/show_bug.cgi?id=739754
This commit is contained in:
parent
038cc7b004
commit
3282df51a4
1 changed files with 17 additions and 3 deletions
|
@ -70,7 +70,7 @@ static void gst_v4l2_buffer_pool_release_buffer (GstBufferPool * bpool,
|
||||||
GstBuffer * buffer);
|
GstBuffer * buffer);
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_v4l2_is_buffer_valid (GstBuffer * buffer, GstV4l2MemoryGroup ** group)
|
gst_v4l2_is_buffer_valid (GstBuffer * buffer, GstV4l2MemoryGroup ** out_group)
|
||||||
{
|
{
|
||||||
GstMemory *mem = gst_buffer_peek_memory (buffer, 0);
|
GstMemory *mem = gst_buffer_peek_memory (buffer, 0);
|
||||||
gboolean valid = FALSE;
|
gboolean valid = FALSE;
|
||||||
|
@ -84,9 +84,23 @@ gst_v4l2_is_buffer_valid (GstBuffer * buffer, GstV4l2MemoryGroup ** group)
|
||||||
|
|
||||||
if (mem && gst_is_v4l2_memory (mem)) {
|
if (mem && gst_is_v4l2_memory (mem)) {
|
||||||
GstV4l2Memory *vmem = (GstV4l2Memory *) mem;
|
GstV4l2Memory *vmem = (GstV4l2Memory *) mem;
|
||||||
|
GstV4l2MemoryGroup *group = vmem->group;
|
||||||
|
gint i;
|
||||||
|
|
||||||
|
if (group->n_mem != gst_buffer_n_memory (buffer))
|
||||||
|
goto done;
|
||||||
|
|
||||||
|
for (i = 0; i < group->n_mem; i++) {
|
||||||
|
if (group->mem[i] != gst_buffer_peek_memory (buffer, i))
|
||||||
|
goto done;
|
||||||
|
|
||||||
|
if (!gst_memory_is_writable (group->mem[i]))
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
valid = TRUE;
|
valid = TRUE;
|
||||||
if (group)
|
if (out_group)
|
||||||
*group = vmem->group;
|
*out_group = group;
|
||||||
}
|
}
|
||||||
|
|
||||||
done:
|
done:
|
||||||
|
|
Loading…
Reference in a new issue