diff options
author | Xiang, Haihao <haihao.xiang@intel.com> | 2011-05-16 11:42:51 +0800 |
---|---|---|
committer | Xiang, Haihao <haihao.xiang@intel.com> | 2011-05-16 11:57:12 +0800 |
commit | db1a88d199aa906b2aad1b5046e55151f6320dac (patch) | |
tree | e54f3cf078be65ae6e6ea661696c46cb3c6e013a | |
parent | 25040889c144b9ce7779bdbd7da03e4bbfee58f8 (diff) | |
download | libva-db1a88d199aa906b2aad1b5046e55151f6320dac.tar.gz |
va: always create a new VA display on X11
Previously a VA display will be shared if a native display is shared by
multiple threads, it will casue some thread safety issue in a multi-threaded
program.
Signed-off-by: Xiang, Haihao <haihao.xiang@intel.com>
-rw-r--r-- | va/x11/va_x11.c | 44 |
1 files changed, 6 insertions, 38 deletions
diff --git a/va/x11/va_x11.c b/va/x11/va_x11.c index 7a917f3..fd7e517 100644 --- a/va/x11/va_x11.c +++ b/va/x11/va_x11.c @@ -42,40 +42,21 @@ #include <fcntl.h> #include <errno.h> -static VADisplayContextP pDisplayContexts = NULL; - static int va_DisplayContextIsValid ( VADisplayContextP pDisplayContext ) { - VADisplayContextP ctx = pDisplayContexts; - - while (ctx) - { - if (ctx == pDisplayContext && pDisplayContext->pDriverContext) - return 1; - ctx = ctx->pNext; - } - return 0; + return (pDisplayContext != NULL && + pDisplayContext->pDriverContext != NULL); } static void va_DisplayContextDestroy ( VADisplayContextP pDisplayContext ) { - VADisplayContextP *ctx = &pDisplayContexts; - - /* Throw away pDisplayContext */ - while (*ctx) - { - if (*ctx == pDisplayContext) - { - *ctx = pDisplayContext->pNext; - pDisplayContext->pNext = NULL; - break; - } - ctx = &((*ctx)->pNext); - } + if (pDisplayContext == NULL) + return; + free(pDisplayContext->pDriverContext->dri_state); free(pDisplayContext->pDriverContext); free(pDisplayContext); @@ -175,22 +156,11 @@ VADisplay vaGetDisplay ( ) { VADisplay dpy = NULL; - VADisplayContextP pDisplayContext = pDisplayContexts; + VADisplayContextP pDisplayContext; if (!native_dpy) return NULL; - while (pDisplayContext) - { - if (pDisplayContext->pDriverContext && - pDisplayContext->pDriverContext->native_dpy == (void *)native_dpy) - { - dpy = (VADisplay)pDisplayContext; - break; - } - pDisplayContext = pDisplayContext->pNext; - } - if (!dpy) { /* create new entry */ @@ -204,13 +174,11 @@ VADisplay vaGetDisplay ( pDisplayContext->vadpy_magic = VA_DISPLAY_MAGIC; pDriverContext->native_dpy = (void *)native_dpy; - pDisplayContext->pNext = pDisplayContexts; pDisplayContext->pDriverContext = pDriverContext; pDisplayContext->vaIsValid = va_DisplayContextIsValid; pDisplayContext->vaDestroy = va_DisplayContextDestroy; pDisplayContext->vaGetDriverName = va_DisplayContextGetDriverName; pDisplayContext->opaque = NULL; - pDisplayContexts = pDisplayContext; pDriverContext->dri_state = dri_state; dpy = (VADisplay)pDisplayContext; } |