kmssink: Do not provide DMA buffer pool for non-linear caps

The dumb allocator does not support modifiers, so we can not allocate
non-linear buffers by ourself.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5174>
This commit is contained in:
He Junyan 2024-05-24 12:26:20 +08:00
parent e4d7ac5989
commit 6ad6b765ab

View file

@ -1721,7 +1721,7 @@ gst_kms_sink_propose_allocation (GstBaseSink * bsink, GstQuery * query)
GstKMSSink *self; GstKMSSink *self;
GstCaps *caps; GstCaps *caps;
gboolean need_pool; gboolean need_pool;
GstVideoInfo vinfo; GstVideoInfoDmaDrm vinfo_drm;
GstBufferPool *pool; GstBufferPool *pool;
gsize size; gsize size;
@ -1732,13 +1732,28 @@ gst_kms_sink_propose_allocation (GstBaseSink * bsink, GstQuery * query)
gst_query_parse_allocation (query, &caps, &need_pool); gst_query_parse_allocation (query, &caps, &need_pool);
if (!caps) if (!caps)
goto no_caps; goto no_caps;
if (!gst_video_info_from_caps (&vinfo, caps))
goto invalid_caps;
size = GST_VIDEO_INFO_SIZE (&vinfo); if (gst_video_is_dma_drm_caps (caps)) {
if (!gst_video_info_dma_drm_from_caps (&vinfo_drm, caps))
goto invalid_caps;
} else {
if (!gst_video_info_from_caps (&vinfo_drm.vinfo, caps))
goto invalid_caps;
vinfo_drm.drm_modifier = DRM_FORMAT_MOD_LINEAR;
}
size = GST_VIDEO_INFO_SIZE (&vinfo_drm.vinfo);
pool = NULL; pool = NULL;
if (need_pool) { if (need_pool) {
if (vinfo_drm.drm_modifier != DRM_FORMAT_MOD_LINEAR) {
/* DUMB allocator (which is the only thing we have right now) does not
* support modifiers */
GST_DEBUG_OBJECT (bsink,
"can't offer a pool supporting non-linear modifiers");
goto out;
}
pool = gst_kms_sink_create_pool (self, caps, size, 0); pool = gst_kms_sink_create_pool (self, caps, size, 0);
if (!pool) if (!pool)
goto no_pool; goto no_pool;
@ -1757,6 +1772,7 @@ gst_kms_sink_propose_allocation (GstBaseSink * bsink, GstQuery * query)
if (pool) if (pool)
gst_object_unref (pool); gst_object_unref (pool);
out:
gst_query_add_allocation_meta (query, GST_VIDEO_META_API_TYPE, NULL); gst_query_add_allocation_meta (query, GST_VIDEO_META_API_TYPE, NULL);
gst_query_add_allocation_meta (query, GST_VIDEO_CROP_META_API_TYPE, NULL); gst_query_add_allocation_meta (query, GST_VIDEO_CROP_META_API_TYPE, NULL);