Commit db1a88d1 authored by Xiang, Haihao's avatar Xiang, Haihao

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: default avatarXiang, Haihao <haihao.xiang@intel.com>
parent 25040889
...@@ -42,40 +42,21 @@ ...@@ -42,40 +42,21 @@
#include <fcntl.h> #include <fcntl.h>
#include <errno.h> #include <errno.h>
static VADisplayContextP pDisplayContexts = NULL;
static int va_DisplayContextIsValid ( static int va_DisplayContextIsValid (
VADisplayContextP pDisplayContext VADisplayContextP pDisplayContext
) )
{ {
VADisplayContextP ctx = pDisplayContexts; return (pDisplayContext != NULL &&
pDisplayContext->pDriverContext != NULL);
while (ctx)
{
if (ctx == pDisplayContext && pDisplayContext->pDriverContext)
return 1;
ctx = ctx->pNext;
}
return 0;
} }
static void va_DisplayContextDestroy ( static void va_DisplayContextDestroy (
VADisplayContextP pDisplayContext VADisplayContextP pDisplayContext
) )
{ {
VADisplayContextP *ctx = &pDisplayContexts; if (pDisplayContext == NULL)
return;
/* Throw away pDisplayContext */
while (*ctx)
{
if (*ctx == pDisplayContext)
{
*ctx = pDisplayContext->pNext;
pDisplayContext->pNext = NULL;
break;
}
ctx = &((*ctx)->pNext);
}
free(pDisplayContext->pDriverContext->dri_state); free(pDisplayContext->pDriverContext->dri_state);
free(pDisplayContext->pDriverContext); free(pDisplayContext->pDriverContext);
free(pDisplayContext); free(pDisplayContext);
...@@ -175,22 +156,11 @@ VADisplay vaGetDisplay ( ...@@ -175,22 +156,11 @@ VADisplay vaGetDisplay (
) )
{ {
VADisplay dpy = NULL; VADisplay dpy = NULL;
VADisplayContextP pDisplayContext = pDisplayContexts; VADisplayContextP pDisplayContext;
if (!native_dpy) if (!native_dpy)
return NULL; return NULL;
while (pDisplayContext)
{
if (pDisplayContext->pDriverContext &&
pDisplayContext->pDriverContext->native_dpy == (void *)native_dpy)
{
dpy = (VADisplay)pDisplayContext;
break;
}
pDisplayContext = pDisplayContext->pNext;
}
if (!dpy) if (!dpy)
{ {
/* create new entry */ /* create new entry */
...@@ -204,13 +174,11 @@ VADisplay vaGetDisplay ( ...@@ -204,13 +174,11 @@ VADisplay vaGetDisplay (
pDisplayContext->vadpy_magic = VA_DISPLAY_MAGIC; pDisplayContext->vadpy_magic = VA_DISPLAY_MAGIC;
pDriverContext->native_dpy = (void *)native_dpy; pDriverContext->native_dpy = (void *)native_dpy;
pDisplayContext->pNext = pDisplayContexts;
pDisplayContext->pDriverContext = pDriverContext; pDisplayContext->pDriverContext = pDriverContext;
pDisplayContext->vaIsValid = va_DisplayContextIsValid; pDisplayContext->vaIsValid = va_DisplayContextIsValid;
pDisplayContext->vaDestroy = va_DisplayContextDestroy; pDisplayContext->vaDestroy = va_DisplayContextDestroy;
pDisplayContext->vaGetDriverName = va_DisplayContextGetDriverName; pDisplayContext->vaGetDriverName = va_DisplayContextGetDriverName;
pDisplayContext->opaque = NULL; pDisplayContext->opaque = NULL;
pDisplayContexts = pDisplayContext;
pDriverContext->dri_state = dri_state; pDriverContext->dri_state = dri_state;
dpy = (VADisplay)pDisplayContext; dpy = (VADisplay)pDisplayContext;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment