mirror of
https://github.com/mpv-player/mpv
synced 2024-12-27 09:32:40 +00:00
gl_x11: fail gracefully if selected FBconfig has no X visual
glXGetVisualFromFBConfig() specifies specifies that it can return NULL if there is no associated X visual. Instead of crashing, let initialization fail. I'm not sure if this is actually supposed to work with a fallback visual (passing a NULL visual to vo_x11_config_vo_window would just do this), but let's play safe for now. Apparently this can happen when trying to use vo_opengl over a remote X display.
This commit is contained in:
parent
683e212a77
commit
76f32e3881
@ -162,6 +162,8 @@ static GLXFBConfig select_fb_config(struct vo *vo, const int *attribs, int flags
|
||||
if (flags & VOFLAG_ALPHA) {
|
||||
for (int n = 0; n < fbcount; n++) {
|
||||
XVisualInfo *v = glXGetVisualFromFBConfig(vo->x11->display, fbc[n]);
|
||||
if (!v)
|
||||
continue;
|
||||
// This is a heuristic at best. Note that normal 8 bit Visuals use
|
||||
// a depth of 24, even if the pixels are padded to 32 bit. If the
|
||||
// depth is higher than 24, the remaining bits must be alpha.
|
||||
@ -252,6 +254,10 @@ static bool config_window_x11(struct MPGLContext *ctx, uint32_t d_width,
|
||||
|
||||
glx_ctx->fbc = fbc;
|
||||
glx_ctx->vinfo = glXGetVisualFromFBConfig(vo->x11->display, fbc);
|
||||
if (!glx_ctx->vinfo) {
|
||||
MP_ERR(vo, "Selected GLX FB config has no associated X visual\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
MP_VERBOSE(vo, "GLX chose visual with ID 0x%x\n", (int)glx_ctx->vinfo->visualid);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user