mirror of
https://github.com/LizardByte/Sunshine.git
synced 2025-08-10 00:52:16 +00:00
Fix segfault when switching monitors with kmsgrab
This commit is contained in:
@@ -22,10 +22,6 @@ extern "C" {
|
||||
|
||||
#define SUNSHINE_SHADERS_DIR SUNSHINE_ASSETS_DIR "/shaders/opengl"
|
||||
|
||||
#define STRINGIFY(x) #x
|
||||
#define gl_drain_errors_helper(x) gl::drain_errors("line " STRINGIFY(x))
|
||||
#define gl_drain_errors gl_drain_errors_helper(__LINE__)
|
||||
|
||||
using namespace std::literals;
|
||||
namespace gl {
|
||||
GladGLContext ctx;
|
||||
|
||||
@@ -12,6 +12,10 @@
|
||||
#include "sunshine/platform/common.h"
|
||||
#include "sunshine/utility.h"
|
||||
|
||||
#define SUNSHINE_STRINGIFY(x) #x
|
||||
#define gl_drain_errors_helper(x) gl::drain_errors("line " SUNSHINE_STRINGIFY(x))
|
||||
#define gl_drain_errors gl_drain_errors_helper(__LINE__)
|
||||
|
||||
extern "C" int close(int __fd);
|
||||
|
||||
struct AVFrame;
|
||||
@@ -197,9 +201,7 @@ KITTY_USING_MOVE_T(nv12_t, nv12_img_t, , {
|
||||
KITTY_USING_MOVE_T(ctx_t, (std::tuple<display_t::pointer, EGLContext>), , {
|
||||
TUPLE_2D_REF(disp, ctx, el);
|
||||
if(ctx) {
|
||||
if(ctx == eglGetCurrentContext()) {
|
||||
eglMakeCurrent(disp, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
||||
}
|
||||
eglMakeCurrent(disp, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
||||
eglDestroyContext(disp, ctx);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -396,6 +396,7 @@ public:
|
||||
}
|
||||
|
||||
int dummy_img(platf::img_t *img) override {
|
||||
snapshot(img, 1s, false);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -675,11 +675,10 @@ void captureThread(
|
||||
img.reset();
|
||||
}
|
||||
|
||||
// Some classes of display cannot have multiple instances at once
|
||||
disp.reset();
|
||||
|
||||
// display_wp is modified in this thread only
|
||||
while(!display_wp->expired()) {
|
||||
// Wait for the other shared_ptr's of display to be destroyed.
|
||||
// New displays will only be created in this thread.
|
||||
while(display_wp->use_count() != 1) {
|
||||
std::this_thread::sleep_for(100ms);
|
||||
}
|
||||
|
||||
@@ -695,7 +694,11 @@ void captureThread(
|
||||
return;
|
||||
}
|
||||
|
||||
display_wp = disp;
|
||||
{
|
||||
auto lg = display_wp.lock();
|
||||
display_wp = disp;
|
||||
}
|
||||
|
||||
// Re-allocate images
|
||||
for(auto &img : imgs) {
|
||||
img = disp->alloc_img();
|
||||
|
||||
Reference in New Issue
Block a user