summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Kindestam <antonki@kth.se>2018-02-18 23:51:10 +0100
committerKevin Mitchell <kevmitch@gmail.com>2018-02-26 23:56:13 -0800
commitbb07b22d4248492c859d2e4c0d2ff2941db1db86 (patch)
tree1aef02d4ab06d04794f3eb691462bd29585ba749
parent4d6601924a4d2df557f78f3192236d84f7a4274e (diff)
downloadmpv-bb07b22d4248492c859d2e4c0d2ff2941db1db86.tar.bz2
mpv-bb07b22d4248492c859d2e4c0d2ff2941db1db86.tar.xz
egl_helpers: mpegl_cb can now signal an error condition
This can be used by client code that needs to fail when it cannot find a suitable EGLConfig.
-rw-r--r--video/out/opengl/egl_helpers.c5
-rw-r--r--video/out/opengl/egl_helpers.h4
2 files changed, 8 insertions, 1 deletions
diff --git a/video/out/opengl/egl_helpers.c b/video/out/opengl/egl_helpers.c
index 55bf376973..2de02b3eb4 100644
--- a/video/out/opengl/egl_helpers.c
+++ b/video/out/opengl/egl_helpers.c
@@ -108,6 +108,11 @@ static bool create_context(struct ra_ctx *ctx, EGLDisplay display,
int chosen = 0;
if (cb.refine_config)
chosen = cb.refine_config(cb.user_data, configs, num_configs);
+ if (chosen < 0) {
+ talloc_free(configs);
+ MP_MSG(ctx, msgl, "Could not choose EGLConfig!\n");
+ return false;
+ }
EGLConfig config = configs[chosen];
talloc_free(configs);
diff --git a/video/out/opengl/egl_helpers.h b/video/out/opengl/egl_helpers.h
index eaaf9d7a48..df489daf0c 100644
--- a/video/out/opengl/egl_helpers.h
+++ b/video/out/opengl/egl_helpers.h
@@ -15,7 +15,9 @@ bool mpegl_create_context(struct ra_ctx *ctx, EGLDisplay display,
struct mpegl_cb {
// if set, pick the desired config from the given list and return its index
- // defaults to 0 (they are sorted by eglChooseConfig)
+ // defaults to 0 (they are sorted by eglChooseConfig). return a negative
+ // number to indicate an error condition or that no suitable configs could
+ // be found.
int (*refine_config)(void *user_data, EGLConfig *configs, int num_configs);
void *user_data;
};