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.