From a77c1cbd0b490739e283be8d8241e183412d375b Mon Sep 17 00:00:00 2001 From: Michael Olbrich Date: Tue, 24 Jun 2025 13:00:19 +0200 Subject: [PATCH] gst: pipewireformat: enforce DMA_DRM when possible with memory:DMABuf, DMA_DRM should be used as 'format'. So only add formats to 'format' if there is no equivalent drm format. --- src/gst/gstpipewireformat.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/gst/gstpipewireformat.c b/src/gst/gstpipewireformat.c index d7deb4e40..46d9a228e 100644 --- a/src/gst/gstpipewireformat.c +++ b/src/gst/gstpipewireformat.c @@ -1023,21 +1023,25 @@ handle_dmabuf_prop (const struct spa_pod_prop *prop, for (i = 0; i < n_fmts; i++) { for (j = 0; j < n_mods; j++) { + gboolean as_drm = FALSE; const char *fmt_str; - if ((mods[j] == DRM_FORMAT_MOD_LINEAR || - mods[j] == DRM_FORMAT_MOD_INVALID) && - (fmt_str = video_id_to_string(id[i]))) - g_ptr_array_add(fmt_array, g_strdup_printf ("%s", fmt_str)); - #ifdef HAVE_GSTREAMER_DMA_DRM if (mods[j] != DRM_FORMAT_MOD_INVALID) { char *drm_str; - if ((drm_str = video_id_to_dma_drm_fourcc(id[i], mods[j]))) + if ((drm_str = video_id_to_dma_drm_fourcc(id[i], mods[j]))) { g_ptr_array_add(drm_fmt_array, drm_str); + as_drm = TRUE; + } } #endif + + if (!as_drm && + (mods[j] == DRM_FORMAT_MOD_LINEAR || + mods[j] == DRM_FORMAT_MOD_INVALID) && + (fmt_str = video_id_to_string(id[i]))) + g_ptr_array_add(fmt_array, g_strdup_printf ("%s", fmt_str)); } }