fixed: libvdpau 0.4 installs a callback on the Display*, we need to keep a static...
authorbobo1on1 <bobo1on1@svn>
Sat, 11 Dec 2010 01:57:59 +0000 (01:57 +0000)
committerbobo1on1 <bobo1on1@svn>
Sat, 11 Dec 2010 01:57:59 +0000 (01:57 +0000)
(cherry picked from commit 30b611e4e50cde4f3d1b4e63ed3c72cba0dfbebd)

git-svn-id: https://xbmc.svn.sourceforge.net/svnroot/xbmc/branches/Dharma@35615 568bbfeb-2a22-0410-94d2-cc84cf5bfa90

xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp
xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.h

index a29b569..965c5e2 100644 (file)
@@ -76,12 +76,16 @@ static struct SInterlaceMapping
             return value; \
         } while(0);
 
+//since libvdpau 0.4, vdp_device_create_x11() installs a callback on the Display*,
+//if we unload libvdpau with dlclose(), we segfault on XCloseDisplay,
+//so we just keep a static handle to libvdpau around
+void* CVDPAU::dl_handle;
+
 CVDPAU::CVDPAU()
 {
   glXBindTexImageEXT = NULL;
   glXReleaseTexImageEXT = NULL;
   vdp_device = VDP_INVALID_HANDLE;
-  dl_handle  = NULL;
   surfaceNum      = presentSurfaceNum = 0;
   picAge.b_age    = picAge.ip_age[0] = picAge.ip_age[1] = 256*256*256*64;
   vdpauConfigured = false;
@@ -125,17 +129,20 @@ bool CVDPAU::Open(AVCodecContext* avctx, const enum PixelFormat)
     return false;
   }
 
-  dl_handle  = dlopen("libvdpau.so.1", RTLD_LAZY);
   if (!dl_handle)
   {
-    const char* error = dlerror();
-    if (!error)
-      error = "dlerror() returned NULL";
+    dl_handle  = dlopen("libvdpau.so.1", RTLD_LAZY);
+    if (!dl_handle)
+    {
+      const char* error = dlerror();
+      if (!error)
+        error = "dlerror() returned NULL";
 
-    CLog::Log(LOGNOTICE,"(VDPAU) Unable to get handle to libvdpau: %s", error);
-    //g_application.m_guiDialogKaiToast.QueueNotification(CGUIDialogKaiToast::Error, "VDPAU", error, 10000);
+      CLog::Log(LOGNOTICE,"(VDPAU) Unable to get handle to libvdpau: %s", error);
+      //g_application.m_guiDialogKaiToast.QueueNotification(CGUIDialogKaiToast::Error, "VDPAU", error, 10000);
 
-    return false;
+      return false;
+    }
   }
 
   InitVDPAUProcs();
@@ -227,11 +234,6 @@ void CVDPAU::Close()
     glXDestroyContext(m_Display, m_glContext);
     m_glContext = NULL;
   }
-  if (dl_handle)
-  {
-    dlclose(dl_handle);
-    dl_handle = NULL;
-  }
 }
 
 bool CVDPAU::MakePixmapGL()
index c50229b..15b2f6c 100644 (file)
@@ -195,7 +195,7 @@ public:
   VdpRect       outRect;
   VdpRect       outRectVid;
 
-  void*    dl_handle;
+  static void* dl_handle;
   VdpStatus (*dl_vdp_device_create_x11)(Display* display, int screen, VdpDevice* device, VdpGetProcAddress **get_proc_address);
   VdpStatus (*dl_vdp_get_proc_address)(VdpDevice device, VdpFuncId function_id, void** function_pointer);
   VdpStatus (*dl_vdp_preemption_callback_register)(VdpDevice device, VdpPreemptionCallback callback, void* context);