From 723934d0b0fbf3ccadb7cdcf3ea59b4375279f91 Mon Sep 17 00:00:00 2001 From: columbarius Date: Sun, 5 Jun 2022 10:49:40 +0200 Subject: [PATCH] screencast: check if a valid format was received from wlr_screencopy When a screencast is started we do a roundtrip on get the offered formats from wlr_screencopy. This roundtrip can fail [1]. In this case the formats won't be initialized and we will just error out of the screencast session. [1] https://github.com/emersion/xdg-desktop-portal-wlr/issues/214 --- src/screencast/screencast.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/screencast/screencast.c b/src/screencast/screencast.c index 0a38bbd..04a5676 100644 --- a/src/screencast/screencast.c +++ b/src/screencast/screencast.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -167,6 +168,13 @@ static int start_screencast(struct xdpw_screencast_instance *cast) { wl_display_dispatch(cast->ctx->state->wl_display); wl_display_roundtrip(cast->ctx->state->wl_display); + if (cast->screencopy_frame_info[WL_SHM].format == DRM_FORMAT_INVALID || + (cast->ctx->state->screencast_version >= 3 && + cast->screencopy_frame_info[DMABUF].format == DRM_FORMAT_INVALID)) { + logprint(INFO, "wlroots: unable to receive a valid format from wlr_screencopy"); + return -1; + } + xdpw_pwr_stream_create(cast); cast->initialized = true; @@ -443,7 +451,10 @@ static int method_screencast_start(sd_bus_message *msg, void *data, } if (!cast->initialized) { - start_screencast(cast); + ret = start_screencast(cast); + } + if (ret < 0) { + return ret; } while (cast->node_id == SPA_ID_INVALID) {