diff options
author | wm4 <wm4@nowhere> | 2013-10-03 23:45:49 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2013-10-03 23:50:48 +0200 |
commit | 76f32e3881183b2fd321bd4a3e209d4144e1d323 (patch) | |
tree | 44754d615315b6188c00e0fb2f02d228f38636c7 /video/out/gl_x11.c | |
parent | 683e212a779341a7b376fbb6d5df54cb8205893d (diff) | |
download | mpv-76f32e3881183b2fd321bd4a3e209d4144e1d323.tar.bz2 mpv-76f32e3881183b2fd321bd4a3e209d4144e1d323.tar.xz |
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.
Diffstat (limited to 'video/out/gl_x11.c')
-rw-r--r-- | video/out/gl_x11.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/video/out/gl_x11.c b/video/out/gl_x11.c index a3b3176987..99239d0b30 100644 --- a/video/out/gl_x11.c +++ b/video/out/gl_x11.c @@ -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); |