From 75517d0fafc6ea533c96864c5e64a503b675833d Mon Sep 17 00:00:00 2001 From: Jakub Adam Date: Wed, 27 Nov 2024 23:12:18 +0100 Subject: [PATCH] unixfdsrc: fix allocating FD memory with nonzero offsets The element should allocate GstFdMemory large enough to fit incoming memory's size plus its potential offset. Fixes "gst_memory_resize: assertion 'size + mem->offset + offset <= mem->maxsize' failed". Fixes an issue reproducible on Raspberry Pi 4 that results in a garbled image on the receiver's end: gst-launch-1.0 libcamerasrc ! unixfdsink socket-path=/tmp/socket gst-launch-1.0 unixfdsrc socket-path=/tmp/socket ! autovideosink Part-of: --- subprojects/gst-plugins-bad/gst/unixfd/gstunixfdsrc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/subprojects/gst-plugins-bad/gst/unixfd/gstunixfdsrc.c b/subprojects/gst-plugins-bad/gst/unixfd/gstunixfdsrc.c index cc673061a2..7cf938f2a3 100644 --- a/subprojects/gst-plugins-bad/gst/unixfd/gstunixfdsrc.c +++ b/subprojects/gst-plugins-bad/gst/unixfd/gstunixfdsrc.c @@ -405,10 +405,10 @@ again: ctx->id = new_buffer->id; ctx->n_memory = new_buffer->n_memory; for (int i = 0; i < new_buffer->n_memory; i++) { - GstMemory *mem = gst_fd_allocator_alloc (allocator, fds_arr[i], - new_buffer->memories[i].size, GST_FD_MEMORY_FLAG_NONE); - gst_memory_resize (mem, new_buffer->memories[i].offset, - new_buffer->memories[i].size); + GstMemory *mem = gst_fd_allocator_alloc_full (allocator, fds_arr[i], + new_buffer->memories[i].offset + new_buffer->memories[i].size, + new_buffer->memories[i].offset, new_buffer->memories[i].size, + GST_FD_MEMORY_FLAG_NONE); GST_MINI_OBJECT_FLAG_SET (mem, GST_MEMORY_FLAG_READONLY); g_hash_table_insert (self->memories, mem, ctx);