From d3da92aea4e865b72194ecc76e0eab6e2a1179a3 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sat, 14 Apr 2012 15:02:28 +0200 Subject: [PATCH] cocoa_common, gl_common: add OSX specific getProcAddress Run dlopen on the OpenGL dynamic library instead of on the binary. This should prevent crashes due to function conflicts when X11/lGL is linked. Remove mutual exclusion of the X11 and Cocoa backends. --- configure | 2 +- libvo/cocoa_common.h | 1 + libvo/cocoa_common.m | 15 +++++++++++++++ libvo/gl_common.c | 2 +- 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/configure b/configure index 4a6e209d3a..7b99766d2d 100755 --- a/configure +++ b/configure @@ -4544,7 +4544,7 @@ int main(int argc, char *argv[]) { EOF _gl=no for _ld_tmp in "" -lGL "-lGL -lXdamage" "-lGL $_ld_pthread" ; do - if test "$_cocoa" != yes && cc_check $_ld_tmp $_ld_lm ; then + if cc_check $_ld_tmp $_ld_lm ; then _gl=yes _gl_x11=yes libs_mplayer="$libs_mplayer $_ld_tmp $_ld_dl" diff --git a/libvo/cocoa_common.h b/libvo/cocoa_common.h index 89b0ea663b..e8cd7d9dc4 100644 --- a/libvo/cocoa_common.h +++ b/libvo/cocoa_common.h @@ -23,6 +23,7 @@ #include "video_out.h" bool vo_cocoa_gui_running(void); +void *vo_cocoa_glgetaddr(const char *s); int vo_cocoa_init(struct vo *vo); void vo_cocoa_uninit(struct vo *vo); diff --git a/libvo/cocoa_common.m b/libvo/cocoa_common.m index 63e8e90db4..5cc29cc78b 100644 --- a/libvo/cocoa_common.m +++ b/libvo/cocoa_common.m @@ -21,6 +21,8 @@ #import #import #import // for CGDisplayHideCursor +#include + #include "cocoa_common.h" #include "options.h" @@ -117,6 +119,19 @@ bool vo_cocoa_gui_running(void) return !!s; } +void *vo_cocoa_glgetaddr(const char *s) +{ + void *ret = NULL; + void *handle = dlopen( + "/System/Library/Frameworks/OpenGL.framework/OpenGL", + RTLD_LAZY | RTLD_LOCAL); + if (!handle) + return NULL; + ret = dlsym(handle, s); + dlclose(handle); + return ret; +} + int vo_cocoa_init(struct vo *vo) { s = vo_cocoa_init_state(); diff --git a/libvo/gl_common.c b/libvo/gl_common.c index 30ed50e95e..3b723493db 100644 --- a/libvo/gl_common.c +++ b/libvo/gl_common.c @@ -1628,7 +1628,7 @@ static int create_window_cocoa(struct MPGLContext *ctx, uint32_t d_width, static int setGlWindow_cocoa(MPGLContext *ctx) { vo_cocoa_change_attributes(ctx->vo); - getFunctions(ctx->gl, (void *)getdladdr, NULL); + getFunctions(ctx->gl, (void *)vo_cocoa_glgetaddr, NULL); if (!ctx->gl->SwapInterval) ctx->gl->SwapInterval = vo_cocoa_swap_interval; return SET_WINDOW_OK;