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
This commit is contained in:
columbarius 2022-06-05 10:49:40 +02:00 committed by Simon Ser
parent 0bbd652c1c
commit 723934d0b0

View file

@ -6,6 +6,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include <assert.h> #include <assert.h>
#include <drm_fourcc.h>
#include <sys/wait.h> #include <sys/wait.h>
#include <sys/mman.h> #include <sys/mman.h>
#include <spa/utils/result.h> #include <spa/utils/result.h>
@ -167,6 +168,13 @@ static int start_screencast(struct xdpw_screencast_instance *cast) {
wl_display_dispatch(cast->ctx->state->wl_display); wl_display_dispatch(cast->ctx->state->wl_display);
wl_display_roundtrip(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); xdpw_pwr_stream_create(cast);
cast->initialized = true; cast->initialized = true;
@ -443,7 +451,10 @@ static int method_screencast_start(sd_bus_message *msg, void *data,
} }
if (!cast->initialized) { if (!cast->initialized) {
start_screencast(cast); ret = start_screencast(cast);
}
if (ret < 0) {
return ret;
} }
while (cast->node_id == SPA_ID_INVALID) { while (cast->node_id == SPA_ID_INVALID) {