Skip to content
Snippets Groups Projects
Commit e99be279 authored by Alaric Senat's avatar Alaric Senat Committed by Steve Lhomme
Browse files

libplacebo: avoid casting callbacks

The function signature does not match the libplacebo callback (gl_t*
instead of void*). While this is supported by many platforms and
compilers, it's undefined behavior strictly by the standard [1] and it's
known to often fail with emscripten [^2].

[1]:
Section 6.3.2.3, paragraph 8:

> A pointer to a function of one type may be converted to a pointer to a
> function of another type and back again; the result shall compare
> equal to the original pointer. If a converted pointer is used to call
> a function whose type is not compatible with the pointed-to type, the
> behavior is undefined.

Quoting section 6.7.5.1, paragraph 2 for pointer compatibility:

> For two pointer types to be compatible, both shall be identically
> qualified and both shall be pointers to compatible types.


[^2]: https://emscripten.org/docs/porting/guidelines/function_pointer_issues.html
parent 61c4034f
No related branches found
No related tags found
No related merge requests found
......@@ -37,6 +37,7 @@ static int InitInstance(vlc_placebo_t *pl, const vout_display_cfg_t *cfg);
static void CloseInstance(vlc_placebo_t *pl);
static int MakeCurrent(vlc_placebo_t *pl);
static void ReleaseCurrent(vlc_placebo_t *pl);
static void SwapBuffers(void *);
#define GL_TEXT N_("OpenGL extension")
#define GLES2_TEXT N_("OpenGL ES 2 extension")
......@@ -127,7 +128,7 @@ static int InitInstance(vlc_placebo_t *pl, const vout_display_cfg_t *cfg)
// Create swapchain for this surface
struct pl_opengl_swapchain_params swap_params = {
.swap_buffers = (void (*)(void *)) vlc_gl_Swap,
.swap_buffers = SwapBuffers,
.max_swapchain_depth = var_InheritInteger(pl, "gl-swap-depth"),
.priv = sys->gl,
};
......@@ -179,3 +180,8 @@ static void ReleaseCurrent(vlc_placebo_t *pl)
vlc_placebo_system_t *sys = pl->sys;
vlc_gl_ReleaseCurrent(sys->gl);
}
static void SwapBuffers(void *opaque)
{
vlc_gl_Swap(opaque);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment