From 1ab6bbe3a79897d0198847d95f63d682c35eccdc Mon Sep 17 00:00:00 2001 From: Stephen Torri Date: Sat, 2 Nov 2002 21:53:00 +0000 Subject: Thanks to Siggi, Bastien, and Robin for their help. Used dlopen to grab reference to XvQueryExtension. Added #ifdef statements to protect doing unnecessary checks if X11 or Xv not installed. (still need work here) Removed X11 libs from xine-config flag (--libs) CVS patchset: 3156 CVS date: 2002/11/02 21:53:00 --- src/xine-utils/xine_check.c | 58 +++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 53 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/xine-utils/xine_check.c b/src/xine-utils/xine_check.c index f14d7f795..653c575a1 100644 --- a/src/xine-utils/xine_check.c +++ b/src/xine-utils/xine_check.c @@ -34,8 +34,14 @@ * Author: Stephen Torri */ #include "xine_check.h" + + +#if defined(__linux__) +#include +#include + #include "xineutils.h" -#include + #include #include #include @@ -43,10 +49,17 @@ #include #include -#if defined(__linux__) -#include -#include +#ifdef HAVE_X11 +#include +#endif + +#ifdef HAVE_XV #include +#endif + +#include + + xine_health_check_t* xine_health_check (xine_health_check_t* hc) { @@ -271,11 +284,17 @@ xine_health_check_x (xine_health_check_t* hc) { xine_health_check_t* xine_health_check_xv (xine_health_check_t* hc) { +#ifdef HAVE_X11 +#ifdef HAVE_XV Display *dpy; unsigned int ver, rev, eventB, reqB, errorB; char * disname = NULL; + void * dl_handle; + int (*xvquery_extension)(int); + char * err = NULL; /* Majority of thi code was taken from or inspired by the xvinfo.c file of XFree86 */ + if(!(dpy = XOpenDisplay(disname))) { char* display_name = ""; if (disname != NULL) { @@ -290,7 +309,23 @@ xine_health_check_xv (xine_health_check_t* hc) { return hc; } - if((Success != XvQueryExtension(dpy, &ver, &rev, &reqB, &eventB, &errorB))) { + dlerror(); /* clear error code */ + dl_handle = dlopen("libXv.a", RTLD_LAZY); + if(!dl_handle) { + hc->msg = dlerror(); + hc->status = XINE_HEALTH_CHECK_FAIL; + return hc; + } + + xvquery_extension = dlsym(dl_handle,"XvQueryExtension"); + + if((err = dlerror()) != NULL) { + hc->msg = err; + hc->status = XINE_HEALTH_CHECK_FAIL; + return hc; + } + + if((Success != (*xvquery_extension)(dpy, &ver, &rev, &reqB, &eventB, &errorB))) { hc->msg = (char*) malloc (sizeof (char) * 80); sprintf(hc->msg, "No X-Video Extension on %s", (disname != NULL) ? disname : XDisplayName(NULL)); hc->status = XINE_HEALTH_CHECK_FAIL; @@ -300,7 +335,20 @@ xine_health_check_xv (xine_health_check_t* hc) { sprintf(hc->msg, "X-Video Extension version %d.%d\n", ver , rev); hc->status = XINE_HEALTH_CHECK_OK; } + dlclose(dl_handle); + return hc; +#else +  hc->msg = (char*) malloc (sizeof (char) * 20); +  sprintf(hc->msg, "No X-Video Extension"); +  hc->status = XINE_HEALTH_CHECK_FAIL; + return hc; +#endif /* ! HAVE_HV */ +#else + hc->msg = (char*) malloc (sizeof (char) * 23); + sprintf(hc->msg, "No X11 windowing system"); + hc->status = XINE_HEALTH_CHECK_FAIL; return hc; +#endif /* ! HAVE_X11 */ } #else /* !__linux__ */ -- cgit v1.2.3