Merge pull request #196 from nowrep/wlsoftware

wlgrab: Fix ram (software encoding) snapshot
This commit is contained in:
loki-47-6F-64 2021-09-03 11:23:52 +02:00 committed by GitHub
commit a1a4ce1af8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 12 deletions

View File

@ -164,11 +164,14 @@ void dmabuf_t::frame(
std::uint32_t obj_count) {
auto next_frame = get_next_frame();
next_frame->sd.fourcc = format;
next_frame->sd.width = width;
next_frame->sd.height = height;
next_frame->sd.modifier = (((std::uint64_t)high) << 32) | low;
next_frame->obj_count = obj_count;
next_frame->sd.fourcc = format;
next_frame->sd.width = width;
next_frame->sd.height = height;
next_frame->sd.modifier = (((std::uint64_t)high) << 32) | low;
next_frame->sd.obj_count = obj_count;
next_frame->close_fds = true;
std::fill_n(next_frame->sd.fds + obj_count, 4 - obj_count, -1);
}
void dmabuf_t::object(
@ -212,11 +215,15 @@ void dmabuf_t::cancel(
}
void frame_t::destroy() {
for(auto x = 0; x < obj_count; ++x) {
close(sd.fds[x]);
if(!close_fds) {
return;
}
obj_count = 0;
for(auto x = 0; x < 4; ++x) {
if(sd.fds[x] >= 0) {
close(sd.fds[x]);
}
}
close_fds = false;
}
std::vector<std::unique_ptr<monitor_t>> monitors(const char *display_name) {

View File

@ -23,7 +23,7 @@ class frame_t {
public:
egl::surface_descriptor_t sd;
std::uint32_t obj_count;
bool close_fds = false;
void destroy();
};

View File

@ -261,10 +261,9 @@ public:
img->sequence = sequence;
img->sd = current_frame->sd;
img->sd.obj_count = current_frame->obj_count;
// Prevent dmabuf from closing the file descriptors.
current_frame->obj_count = 0;
current_frame->close_fds = false;
return platf::capture_e::ok;
}