From 03b50d4bf6cbedafdb2817a03c6389e10cb86080 Mon Sep 17 00:00:00 2001 From: wm4 Date: Thu, 21 Jan 2016 13:32:29 +0100 Subject: vo_opengl: vaapi: reorganize platform entrypoints as table --- video/out/opengl/hwdec_vaegl.c | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) (limited to 'video/out') diff --git a/video/out/opengl/hwdec_vaegl.c b/video/out/opengl/hwdec_vaegl.c index d37c9d55dc..62a555b1c9 100644 --- a/video/out/opengl/hwdec_vaegl.c +++ b/video/out/opengl/hwdec_vaegl.c @@ -78,27 +78,32 @@ static VADisplay *create_drm_va_display(GL *gl) } #endif -static VADisplay *create_native_va_display(GL *gl) -{ - if (!gl->MPGetNativeDisplay) - return NULL; - VADisplay *display = NULL; +struct va_create_native { + VADisplay *(*create)(GL *gl); +}; + +static const struct va_create_native create_native_cbs[] = { #if HAVE_VAAPI_X11 - display = create_x11_va_display(gl); - if (display) - return display; + {create_x11_va_display}, #endif #if HAVE_VAAPI_WAYLAND - display = create_wayland_va_display(gl); - if (display) - return display; + {create_wayland_va_display}, #endif #if HAVE_VAAPI_DRM - display = create_drm_va_display(gl); - if (display) - return display; + {create_drm_va_display}, #endif - return display; +}; + +static VADisplay *create_native_va_display(GL *gl) +{ + if (!gl->MPGetNativeDisplay) + return NULL; + for (int n = 0; n < MP_ARRAY_SIZE(create_native_cbs); n++) { + VADisplay *display = create_native_cbs[n].create(gl); + if (display) + return display; + } + return NULL; } struct priv { -- cgit v1.2.3