From 4dfdaf67db9a575d0b61146da209972ea8b0b230 Mon Sep 17 00:00:00 2001 From: Hou Qi Date: Wed, 17 Apr 2024 10:58:00 +0900 Subject: [PATCH] waylandsink: config buffer pool with query size when propose_allocation If propose_allocation comes before set_caps, self->video_info has not been extracted from caps and self->video_info.size is 0. It causes buffer pool fail to set config . So need to use info size got from query instead when propose_allocation. Part-of: --- .../ext/wayland/gstwaylandsink.c | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/subprojects/gst-plugins-bad/ext/wayland/gstwaylandsink.c b/subprojects/gst-plugins-bad/ext/wayland/gstwaylandsink.c index 52f5e619c8..1bf537c9f3 100644 --- a/subprojects/gst-plugins-bad/ext/wayland/gstwaylandsink.c +++ b/subprojects/gst-plugins-bad/ext/wayland/gstwaylandsink.c @@ -758,26 +758,41 @@ unsupported_format: static gboolean gst_wayland_sink_propose_allocation (GstBaseSink * bsink, GstQuery * query) { - GstWaylandSink *self = GST_WAYLAND_SINK (bsink); GstCaps *caps; GstBufferPool *pool = NULL; gboolean need_pool; GstAllocator *alloc; + GstVideoInfoDmaDrm drm_info; + GstVideoInfo vinfo; + guint size; gst_query_parse_allocation (query, &caps, &need_pool); + if (caps == NULL) + return FALSE; + + if (gst_video_is_dma_drm_caps (caps)) { + if (!gst_video_info_dma_drm_from_caps (&drm_info, caps)) + return FALSE; + size = drm_info.vinfo.size; + } else { + /* extract info from caps */ + if (!gst_video_info_from_caps (&vinfo, caps)) + return FALSE; + size = vinfo.size; + } + if (need_pool) { GstStructure *config; pool = gst_wl_video_buffer_pool_new (); config = gst_buffer_pool_get_config (pool); - gst_buffer_pool_config_set_params (config, - caps, self->video_info.size, 2, 0); + gst_buffer_pool_config_set_params (config, caps, size, 2, 0); gst_buffer_pool_config_set_allocator (config, gst_shm_allocator_get (), NULL); gst_buffer_pool_set_config (pool, config); } - gst_query_add_allocation_pool (query, pool, self->video_info.size, 2, 0); + gst_query_add_allocation_pool (query, pool, size, 2, 0); if (pool) g_object_unref (pool);