summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-09-26 20:27:21 +0200
committerwm4 <wm4@nowhere>2015-09-26 20:52:10 +0200
commit0aa548457f9b1ba6cb845b3b02a5d84ccec8c108 (patch)
treed5c85bbbb5e881edf65e34e468210e2ca52880d2
parente0cb65e8ac434785f735a40ede1deb44fcb57bdb (diff)
downloadmpv-0aa548457f9b1ba6cb845b3b02a5d84ccec8c108.tar.bz2
mpv-0aa548457f9b1ba6cb845b3b02a5d84ccec8c108.tar.xz
vo_opengl: x11egl: cleanup uninit path
Get rid of the config_window_x11_egl() indirection.
-rw-r--r--video/out/opengl/x11egl.c56
1 files changed, 26 insertions, 30 deletions
diff --git a/video/out/opengl/x11egl.c b/video/out/opengl/x11egl.c
index 87e0e89fff..1559e5ba8a 100644
--- a/video/out/opengl/x11egl.c
+++ b/video/out/opengl/x11egl.c
@@ -46,6 +46,19 @@ static void * GLAPIENTRY get_native_display(const char *name)
return NULL;
}
+static void mpegl_uninit(MPGLContext *ctx)
+{
+ struct priv *p = ctx->priv;
+ if (p->egl_context) {
+ eglMakeCurrent(p->egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE,
+ EGL_NO_CONTEXT);
+ eglDestroyContext(p->egl_display, p->egl_context);
+ }
+ p->egl_context = EGL_NO_CONTEXT;
+ current_context = NULL;
+ vo_x11_uninit(ctx->vo);
+}
+
static EGLConfig select_fb_config_egl(struct MPGLContext *ctx, bool es)
{
struct priv *p = ctx->priv;
@@ -105,28 +118,31 @@ static bool create_context_egl(MPGLContext *ctx, EGLConfig config,
return true;
}
-static bool config_window_x11_egl(struct MPGLContext *ctx, int flags)
+static int mpegl_init(struct MPGLContext *ctx, int flags)
{
struct priv *p = ctx->priv;
struct vo *vo = ctx->vo;
bool es = flags & VOFLAG_GLES;
+ if (!vo_x11_init(vo))
+ goto uninit;
+
p->x_display = vo->x11->display;
if (!eglBindAPI(es ? EGL_OPENGL_ES_API : EGL_OPENGL_API)) {
MP_FATAL(vo, "Could not bind API (%s).\n", es ? "GLES" : "GL");
- return false;
+ goto uninit;
}
p->egl_display = eglGetDisplay(vo->x11->display);
if (!eglInitialize(p->egl_display, NULL, NULL)) {
MP_FATAL(vo, "Could not initialize EGL.\n");
- return false;
+ goto uninit;
}
EGLConfig config = select_fb_config_egl(ctx, es);
if (!config)
- return false;
+ goto uninit;
int vID, n;
eglGetConfigAttrib(p->egl_display, config, EGL_NATIVE_VISUAL_ID, &vID);
@@ -134,8 +150,8 @@ static bool config_window_x11_egl(struct MPGLContext *ctx, int flags)
XVisualInfo *vi = XGetVisualInfo(vo->x11->display, VisualIDMask, &template, &n);
if (!vi) {
- MP_FATAL(ctx->vo, "Getting X visual failed!\n");
- return false;
+ MP_FATAL(vo, "Getting X visual failed!\n");
+ goto uninit;
}
vo_x11_config_vo_window(vo, vi, flags | VOFLAG_HIDDEN, "gl");
@@ -143,10 +159,7 @@ static bool config_window_x11_egl(struct MPGLContext *ctx, int flags)
XFree(vi);
if (!create_context_egl(ctx, config, (EGLNativeWindowType)vo->x11->window, es))
- {
- vo_x11_uninit(ctx->vo);
- return false;
- }
+ goto uninit;
const char *egl_exts = eglQueryString(p->egl_display, EGL_EXTENSIONS);
@@ -157,14 +170,10 @@ static bool config_window_x11_egl(struct MPGLContext *ctx, int flags)
assert(!current_context);
current_context = p;
return true;
-}
-static int mpegl_init(struct MPGLContext *ctx, int vo_flags)
-{
- if (vo_x11_init(ctx->vo) && config_window_x11_egl(ctx, vo_flags))
- return 0;
- vo_x11_uninit(ctx->vo);
- return -1;
+uninit:
+ mpegl_uninit(ctx);
+ return false;
}
static int mpegl_reconfig(struct MPGLContext *ctx, int flags)
@@ -179,19 +188,6 @@ static int mpegl_control(struct MPGLContext *ctx, int *events, int request,
return vo_x11_control(ctx->vo, events, request, arg);
}
-static void mpegl_uninit(MPGLContext *ctx)
-{
- struct priv *p = ctx->priv;
- if (p->egl_context) {
- eglMakeCurrent(p->egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE,
- EGL_NO_CONTEXT);
- eglDestroyContext(p->egl_display, p->egl_context);
- }
- p->egl_context = EGL_NO_CONTEXT;
- current_context = NULL;
- vo_x11_uninit(ctx->vo);
-}
-
static void mpegl_swap_buffers(MPGLContext *ctx)
{
struct priv *p = ctx->priv;