From 5e06e100b25503be1522390ce30ed3baadfcfe31 Mon Sep 17 00:00:00 2001 From: Mahyar Koshkouei Date: Wed, 24 Jan 2018 18:57:49 +0000 Subject: [PATCH] Workaround for get_proc_address failing Retroarch currently has an issue where get_proc_address call fails on the Raspberry Pi (https://github.com/libretro/RetroArch/issues/6137). If the call fails, we fall back to loading symbols from libGLESv2.so, if available. Tested working on the Pi 3 with buildroot. Signed-off-by: Mahyar Koshkouei --- Makefile | 2 +- mpv-libretro.c | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 4026913..d98b77c 100644 --- a/Makefile +++ b/Makefile @@ -118,7 +118,7 @@ else endif OBJECTS := mpv-libretro.o -LDFLAGS += -lmpv +LDFLAGS += -lmpv -ldl CFLAGS += -Wall -pedantic all: $(TARGET) diff --git a/mpv-libretro.c b/mpv-libretro.c index baf9183..35c8176 100644 --- a/mpv-libretro.c +++ b/mpv-libretro.c @@ -15,6 +15,7 @@ * along with this program. If not, see . */ +#include #include #include #include @@ -122,6 +123,20 @@ static void *get_proc_address_mpv(void *fn_ctx, const char *name) void *proc_addr = (void *) hw_render.get_proc_address(name); #pragma GCC diagnostic pop + // EGL 1.4 (supported by the RPI firmware) does not necessarily return + // function pointers for core functions. + if (!proc_addr) { + void *h = dlopen("/opt/vc/lib/libGLESv2.so", RTLD_LAZY); + + if (!h) + h = dlopen("/usr/lib/libGLESv2.so", RTLD_LAZY); + + if (h) { + proc_addr = dlsym(h, name); + dlclose(h); + } + } + if(proc_addr == NULL) log_cb(RETRO_LOG_ERROR, "Failure obtaining %s proc address\n", name); @@ -287,6 +302,7 @@ static void context_reset(void) goto err; } + /* Keep trying until mpv accepts the property. This is done to seek to the * point in the file after the previous context was destroyed. If no * context was destroyed previously, the file seeks to 0.