Skip to content

Commit 8f47190

Browse files
committed
Test for availability of crct info before using it
1 parent 69eba9c commit 8f47190

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

sunshine/platform/linux/kmsgrab.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -950,6 +950,10 @@ void correlate_to_wayland(std::vector<kms::card_descriptor_t> &cds) {
950950
std::vector<std::string> kms_display_names() {
951951
int count = 0;
952952

953+
if(!fs::exists("/dev/dri")) {
954+
BOOST_LOG(warning) << "Couldn't find /dev/dri, kmsgrab won't be enabled"sv;
955+
}
956+
953957
if(!gbm::create_device) {
954958
BOOST_LOG(warning) << "libgbm not initialized"sv;
955959
return {};

sunshine/platform/linux/x11grab.cpp

+15-8
Original file line numberDiff line numberDiff line change
@@ -421,14 +421,21 @@ struct x11_attr_t : public display_t {
421421
return -1;
422422
}
423423

424-
crtc_info_t crt_info { x11::rr::GetCrtcInfo(xdisplay.get(), screenr.get(), result->crtc) };
425-
BOOST_LOG(info)
426-
<< "Streaming display: "sv << result->name << " with res "sv << crt_info->width << 'x' << crt_info->height << " offset by "sv << crt_info->x << 'x' << crt_info->y;
427-
428-
width = crt_info->width;
429-
height = crt_info->height;
430-
offset_x = crt_info->x;
431-
offset_y = crt_info->y;
424+
if(result->crtc) {
425+
crtc_info_t crt_info { x11::rr::GetCrtcInfo(xdisplay.get(), screenr.get(), result->crtc) };
426+
BOOST_LOG(info)
427+
<< "Streaming display: "sv << result->name << " with res "sv << crt_info->width << 'x' << crt_info->height << " offset by "sv << crt_info->x << 'x' << crt_info->y;
428+
429+
width = crt_info->width;
430+
height = crt_info->height;
431+
offset_x = crt_info->x;
432+
offset_y = crt_info->y;
433+
}
434+
else {
435+
BOOST_LOG(warning) << "Couldn't get requested display info, defaulting to recording entire virtual desktop"sv;
436+
width = xattr.width;
437+
height = xattr.height;
438+
}
432439
}
433440
else {
434441
width = xattr.width;

0 commit comments

Comments
 (0)