mirror of https://github.com/mpv-player/mpv
vo_opengl: x11: silence error messages when using legacy GL context
glXCreateContextAttribsARB() by design can throw some X11 errors. We ignore these, but we generally still print error messages to the terminal. This was confusing/annoying users, so silence it. The stupid part is that the Xlib error handler is global, so we have to be slightly careful here.
This commit is contained in:
parent
9693e0f57a
commit
b984ec52aa
|
@ -112,11 +112,13 @@ static bool create_context_x11_gl3(struct MPGLContext *ctx, int vo_flags,
|
||||||
GLX_CONTEXT_FLAGS_ARB, ctx_flags,
|
GLX_CONTEXT_FLAGS_ARB, ctx_flags,
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
vo_x11_silence_xlib(1);
|
||||||
GLXContext context = glXCreateContextAttribsARB(vo->x11->display,
|
GLXContext context = glXCreateContextAttribsARB(vo->x11->display,
|
||||||
glx_ctx->fbc, 0, True,
|
glx_ctx->fbc, 0, True,
|
||||||
context_attribs);
|
context_attribs);
|
||||||
|
vo_x11_silence_xlib(-1);
|
||||||
if (!context) {
|
if (!context) {
|
||||||
MP_INFO(vo, "Could not create GL3 context. Retrying with legacy context.\n");
|
MP_VERBOSE(vo, "Could not create GL3 context. Retrying with legacy context.\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
|
|
||||||
#include "vo.h"
|
#include "vo.h"
|
||||||
#include "win_state.h"
|
#include "win_state.h"
|
||||||
|
#include "osdep/atomics.h"
|
||||||
#include "osdep/timer.h"
|
#include "osdep/timer.h"
|
||||||
#include "osdep/subprocess.h"
|
#include "osdep/subprocess.h"
|
||||||
|
|
||||||
|
@ -125,6 +126,7 @@ static const char x11_icon[] =
|
||||||
;
|
;
|
||||||
|
|
||||||
static struct mp_log *x11_error_output;
|
static struct mp_log *x11_error_output;
|
||||||
|
static atomic_int x11_error_silence;
|
||||||
|
|
||||||
static void vo_x11_update_geometry(struct vo *vo);
|
static void vo_x11_update_geometry(struct vo *vo);
|
||||||
static void vo_x11_fullscreen(struct vo *vo);
|
static void vo_x11_fullscreen(struct vo *vo);
|
||||||
|
@ -262,8 +264,11 @@ static void vo_set_cursor_hidden(struct vo *vo, bool cursor_hidden)
|
||||||
static int x11_errorhandler(Display *display, XErrorEvent *event)
|
static int x11_errorhandler(Display *display, XErrorEvent *event)
|
||||||
{
|
{
|
||||||
struct mp_log *log = x11_error_output;
|
struct mp_log *log = x11_error_output;
|
||||||
char msg[60];
|
|
||||||
|
|
||||||
|
if (atomic_load(&x11_error_silence))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
char msg[60];
|
||||||
XGetErrorText(display, event->error_code, (char *) &msg, sizeof(msg));
|
XGetErrorText(display, event->error_code, (char *) &msg, sizeof(msg));
|
||||||
|
|
||||||
mp_err(log, "X11 error: %s\n", msg);
|
mp_err(log, "X11 error: %s\n", msg);
|
||||||
|
@ -276,6 +281,11 @@ static int x11_errorhandler(Display *display, XErrorEvent *event)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void vo_x11_silence_xlib(int dir)
|
||||||
|
{
|
||||||
|
atomic_fetch_add(&x11_error_silence, dir);
|
||||||
|
}
|
||||||
|
|
||||||
static int net_wm_support_state_test(struct vo_x11_state *x11, Atom atom)
|
static int net_wm_support_state_test(struct vo_x11_state *x11, Atom atom)
|
||||||
{
|
{
|
||||||
#define NET_WM_STATE_TEST(x) { \
|
#define NET_WM_STATE_TEST(x) { \
|
||||||
|
|
|
@ -130,4 +130,6 @@ bool vo_x11_create_vo_window(struct vo *vo, XVisualInfo *vis,
|
||||||
void vo_x11_config_vo_window(struct vo *vo);
|
void vo_x11_config_vo_window(struct vo *vo);
|
||||||
int vo_x11_control(struct vo *vo, int *events, int request, void *arg);
|
int vo_x11_control(struct vo *vo, int *events, int request, void *arg);
|
||||||
|
|
||||||
|
void vo_x11_silence_xlib(int dir);
|
||||||
|
|
||||||
#endif /* MPLAYER_X11_COMMON_H */
|
#endif /* MPLAYER_X11_COMMON_H */
|
||||||
|
|
Loading…
Reference in New Issue