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: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6666>
This commit is contained in:
Hou Qi 2024-04-17 10:58:00 +09:00 committed by GStreamer Marge Bot
parent 750d53d7e0
commit 4dfdaf67db

View file

@ -758,26 +758,41 @@ unsupported_format:
static gboolean static gboolean
gst_wayland_sink_propose_allocation (GstBaseSink * bsink, GstQuery * query) gst_wayland_sink_propose_allocation (GstBaseSink * bsink, GstQuery * query)
{ {
GstWaylandSink *self = GST_WAYLAND_SINK (bsink);
GstCaps *caps; GstCaps *caps;
GstBufferPool *pool = NULL; GstBufferPool *pool = NULL;
gboolean need_pool; gboolean need_pool;
GstAllocator *alloc; GstAllocator *alloc;
GstVideoInfoDmaDrm drm_info;
GstVideoInfo vinfo;
guint size;
gst_query_parse_allocation (query, &caps, &need_pool); 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) { if (need_pool) {
GstStructure *config; GstStructure *config;
pool = gst_wl_video_buffer_pool_new (); pool = gst_wl_video_buffer_pool_new ();
config = gst_buffer_pool_get_config (pool); config = gst_buffer_pool_get_config (pool);
gst_buffer_pool_config_set_params (config, gst_buffer_pool_config_set_params (config, caps, size, 2, 0);
caps, self->video_info.size, 2, 0);
gst_buffer_pool_config_set_allocator (config, gst_buffer_pool_config_set_allocator (config,
gst_shm_allocator_get (), NULL); gst_shm_allocator_get (), NULL);
gst_buffer_pool_set_config (pool, config); 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) if (pool)
g_object_unref (pool); g_object_unref (pool);