Skip to content

Commit

Permalink
screencast: check if a valid format was received from wlr_screencopy
Browse files Browse the repository at this point in the history
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] #214
  • Loading branch information
columbarius authored and emersion committed Jun 9, 2022
1 parent 0bbd652 commit 723934d
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/screencast/screencast.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <stdlib.h>
#include <unistd.h>
#include <assert.h>
#include <drm_fourcc.h>
#include <sys/wait.h>
#include <sys/mman.h>
#include <spa/utils/result.h>
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 723934d

Please sign in to comment.