From: Xiang, Haihao Date: Mon, 16 May 2011 03:42:51 +0000 (+0800) Subject: va: always create a new VA display on X11 X-Git-Tag: libva-1.0.13~10 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=db1a88d199aa906b2aad1b5046e55151f6320dac;p=platform%2Fupstream%2Flibva.git 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 --- 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 #include -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; }