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 <mahyar.koshkouei@gmail.com>
This commit is contained in:
Mahyar Koshkouei 2018-01-24 18:57:49 +00:00
parent 3642b31b8a
commit 5e06e100b2
2 changed files with 17 additions and 1 deletions

View File

@ -118,7 +118,7 @@ else
endif
OBJECTS := mpv-libretro.o
LDFLAGS += -lmpv
LDFLAGS += -lmpv -ldl
CFLAGS += -Wall -pedantic
all: $(TARGET)

View File

@ -15,6 +15,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <dlfcn.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
@ -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.