From 621c06dedaf9ea9813c63229cc9ddafbabb70be5 Mon Sep 17 00:00:00 2001 From: Columbariu s Date: Sun, 5 Dec 2021 18:47:45 +0100 Subject: [PATCH] screencast: Fix format announced with SHM enum format Kwin announces a format with alpha when Dma-Bufs are available, even when the texture doesn't contain any. This results in clients segfault when trying to access the buffer assuming a maxsize wrt. the announced format by ways of dimensions and bpp. This patch moves the format masking to affect the Dma-Buf transport only. --- src/plugins/screencast/screencaststream.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/screencast/screencaststream.cpp b/src/plugins/screencast/screencaststream.cpp index ee3682c119..2932e62a90 100644 --- a/src/plugins/screencast/screencaststream.cpp +++ b/src/plugins/screencast/screencaststream.cpp @@ -280,10 +280,10 @@ bool ScreenCastStream::createStream() auto canCreateDmaBuf = [this] () -> bool { return QSharedPointer(kwinApp()->platform()->createDmaBufTexture(m_resolution)); }; - const auto format = m_source->hasAlphaChannel() || canCreateDmaBuf() ? SPA_VIDEO_FORMAT_BGRA : SPA_VIDEO_FORMAT_BGR; + const auto format = m_source->hasAlphaChannel() ? SPA_VIDEO_FORMAT_BGRA : SPA_VIDEO_FORMAT_BGR; if (canCreateDmaBuf()) { - params[0] = buildFormat(&podBuilder, format, &resolution, &defaultFramerate, &minFramerate, &maxFramerate, &modifier, 1); + params[0] = buildFormat(&podBuilder, SPA_VIDEO_FORMAT_BGRA, &resolution, &defaultFramerate, &minFramerate, &maxFramerate, &modifier, 1); params[1] = buildFormat(&podBuilder, format, &resolution, &defaultFramerate, &minFramerate, &maxFramerate, nullptr, 0); n_params = 2; } else {