mirror of
https://github.com/LizardByte/Sunshine.git
synced 2025-08-10 00:52:16 +00:00
Fix file descriptor leak
This commit is contained in:
@@ -247,4 +247,5 @@
|
||||
# To set the initial state of flags -0 and -1 to on, set the following flags:
|
||||
# flags = 01
|
||||
#
|
||||
# See: sunshine --help for all options under the header: flags
|
||||
# See: sunshine --help for all options under the header: flags
|
||||
adapter_name=/dev/dri/renderD129
|
||||
@@ -581,6 +581,11 @@ struct nv12_img_t {
|
||||
|
||||
gl::tex_t tex;
|
||||
gl::frame_buf_t buf;
|
||||
|
||||
static constexpr std::size_t num_fds =
|
||||
sizeof(va::DRMPRIMESurfaceDescriptor::objects) / sizeof(va::DRMPRIMESurfaceDescriptor::objects[0]);
|
||||
|
||||
std::array<file_t, num_fds> fds;
|
||||
};
|
||||
|
||||
KITTY_USING_MOVE_T(nv12_t, nv12_img_t, , {
|
||||
@@ -626,6 +631,12 @@ public:
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
// Keep track of file descriptors
|
||||
std::array<file_t, nv12_img_t::num_fds> fds;
|
||||
for(int x = 0; x < prime.num_objects; ++x) {
|
||||
fds[x] = prime.objects[x].fd;
|
||||
}
|
||||
|
||||
int img_attr_planes[2][13] {
|
||||
{ EGL_LINUX_DRM_FOURCC_EXT, DRM_FORMAT_R8,
|
||||
EGL_WIDTH, (int)prime.width,
|
||||
@@ -649,7 +660,8 @@ public:
|
||||
eglCreateImageKHR(display.get(), EGL_NO_CONTEXT, EGL_LINUX_DMA_BUF_EXT, nullptr, img_attr_planes[0]),
|
||||
eglCreateImageKHR(display.get(), EGL_NO_CONTEXT, EGL_LINUX_DMA_BUF_EXT, nullptr, img_attr_planes[1]),
|
||||
gl::tex_t::make(2),
|
||||
gl::frame_buf_t::make(2)
|
||||
gl::frame_buf_t::make(2),
|
||||
std::move(fds)
|
||||
};
|
||||
|
||||
if(!nv12->r8 || !nv12->bg88) {
|
||||
|
||||
@@ -33,7 +33,7 @@ struct argument_type<T(U)> { typedef U type; };
|
||||
move_t(Args &&...args) : el { std::forward<Args>(args)... } {} \
|
||||
move_t(const move_t &) = delete; \
|
||||
\
|
||||
explicit move_t(move_t &&other) : el { std::move(other.el) } { \
|
||||
move_t(move_t &&other) noexcept : el { std::move(other.el) } { \
|
||||
other.el = element_type { init_val }; \
|
||||
} \
|
||||
\
|
||||
|
||||
Reference in New Issue
Block a user