void *native_dpy /* implementation specific */
)
{
- VADisplay dpy = NULL;
VADisplayContextP pDisplayContext;
+ VADriverContextP pDriverContext;
+ struct drm_state *drm_state;
if (!native_dpy)
return NULL;
- if (!dpy)
- {
- /* create new entry */
- VADriverContextP pDriverContext = 0;
- struct drm_state *drm_state = 0;
- pDisplayContext = va_newDisplayContext();
- pDriverContext = (VADriverContextP)calloc(1, sizeof(*pDriverContext));
- drm_state = (struct drm_state*)calloc(1, sizeof(*drm_state));
- if (pDisplayContext && pDriverContext && drm_state)
- {
- pDriverContext->native_dpy = (void *)native_dpy;
- pDriverContext->display_type = VA_DISPLAY_ANDROID;
- pDisplayContext->pDriverContext = pDriverContext;
- pDisplayContext->vaIsValid = va_DisplayContextIsValid;
- pDisplayContext->vaDestroy = va_DisplayContextDestroy;
- pDisplayContext->vaGetDriverName = va_DisplayContextGetDriverName;
- pDriverContext->drm_state = drm_state;
- dpy = (VADisplay)pDisplayContext;
- }
- else
- {
- if (pDisplayContext)
- free(pDisplayContext);
- if (pDriverContext)
- free(pDriverContext);
- if (drm_state)
- free(drm_state);
- }
+ pDisplayContext = va_newDisplayContext();
+ if (!pDisplayContext)
+ return NULL;
+
+ pDisplayContext->vaIsValid = va_DisplayContextIsValid;
+ pDisplayContext->vaDestroy = va_DisplayContextDestroy;
+ pDisplayContext->vaGetDriverName = va_DisplayContextGetDriverName;
+
+ pDriverContext = va_newDriverContext(pDisplayContext);
+ if (!pDriverContext) {
+ free(pDisplayContext);
+ return NULL;
}
-
- return dpy;
+
+ pDriverContext->native_dpy = (void *)native_dpy;
+ pDriverContext->display_type = VA_DISPLAY_ANDROID
+
+ drm_state = calloc(1, sizeof(*drm_state));
+ if (!drm_state) {
+ free(pDisplayContext);
+ free(pDriverContext);
+ return NULL;
+ }
+
+ pDriverContext->drm_state = drm_state;
+
+ return (VADisplay)pDisplayContext;
}
goto error;
drm_state->fd = fd;
- pDriverContext = calloc(1, sizeof(*pDriverContext));
- if (!pDriverContext)
- goto error;
- pDriverContext->native_dpy = NULL;
- pDriverContext->display_type = is_render_nodes ?
- VA_DISPLAY_DRM_RENDERNODES : VA_DISPLAY_DRM;
- pDriverContext->drm_state = drm_state;
-
pDisplayContext = va_newDisplayContext();
if (!pDisplayContext)
goto error;
- pDisplayContext->pDriverContext = pDriverContext;
pDisplayContext->vaIsValid = va_DisplayContextIsValid;
pDisplayContext->vaDestroy = va_DisplayContextDestroy;
pDisplayContext->vaGetDriverName = va_DisplayContextGetDriverName;
+
+ pDriverContext = va_newDriverContext(pDisplayContext);
+ if (!pDriverContext)
+ goto error;
+
+ pDriverContext->native_dpy = NULL;
+ pDriverContext->display_type = is_render_nodes ?
+ VA_DISPLAY_DRM_RENDERNODES : VA_DISPLAY_DRM;
+ pDriverContext->drm_state = drm_state;
+
return pDisplayContext;
error:
return dctx;
}
+VADriverContextP va_newDriverContext(VADisplayContextP dctx)
+{
+ VADriverContextP ctx = calloc(1, sizeof(*ctx));
+ if (!ctx)
+ return NULL;
+
+ dctx->pDriverContext = ctx;
+
+ return ctx;
+}
+
static bool va_checkVtable(VADisplay dpy, void *ptr, char *function)
{
if (!ptr) {
VADisplayContextP va_newDisplayContext(void);
+VADriverContextP va_newDriverContext(VADisplayContextP dctx);
+
#ifdef __cplusplus
}
#endif
pDisplayContext->vaDestroy = va_DisplayContextDestroy;
pDisplayContext->vaGetDriverName = va_DisplayContextGetDriverName;
- pDriverContext = calloc(1, sizeof(*pDriverContext));
+ pDriverContext = va_newDriverContext(pDisplayContext);
if (!pDriverContext)
goto error;
- pDisplayContext->pDriverContext = pDriverContext;
pDriverContext->native_dpy = display;
pDriverContext->display_type = VA_DISPLAY_WAYLAND;
Display *native_dpy /* implementation specific */
)
{
- VADisplay dpy = NULL;
- VADisplayContextP pDisplayContext;
-
- if (!native_dpy)
- return NULL;
-
- if (!dpy)
- {
- /* create new entry */
- VADriverContextP pDriverContext;
- struct dri_state *dri_state;
- pDisplayContext = va_newDisplayContext();
- pDriverContext = calloc(1, sizeof(*pDriverContext));
- dri_state = calloc(1, sizeof(*dri_state));
- if (pDisplayContext && pDriverContext && dri_state)
- {
- pDriverContext->native_dpy = (void *)native_dpy;
- pDriverContext->x11_screen = XDefaultScreen(native_dpy);
- pDriverContext->display_type = VA_DISPLAY_X11;
- pDisplayContext->pDriverContext = pDriverContext;
- pDisplayContext->vaIsValid = va_DisplayContextIsValid;
- pDisplayContext->vaDestroy = va_DisplayContextDestroy;
- pDisplayContext->vaGetDriverName = va_DisplayContextGetDriverName;
- pDisplayContext->opaque = NULL;
- pDriverContext->drm_state = dri_state;
- dpy = (VADisplay)pDisplayContext;
- }
- else
- {
- if (pDisplayContext)
- free(pDisplayContext);
- if (pDriverContext)
- free(pDriverContext);
- if (dri_state)
- free(dri_state);
- }
- }
-
- return dpy;
+ VADisplayContextP pDisplayContext;
+ VADriverContextP pDriverContext;
+ struct dri_state *dri_state;
+
+ if (!native_dpy)
+ return NULL;
+
+ pDisplayContext = va_newDisplayContext();
+ if (!pDisplayContext)
+ return NULL;
+
+ pDisplayContext->vaIsValid = va_DisplayContextIsValid;
+ pDisplayContext->vaDestroy = va_DisplayContextDestroy;
+ pDisplayContext->vaGetDriverName = va_DisplayContextGetDriverName;
+
+ pDriverContext = va_newDriverContext(pDisplayContext);
+ if (!pDriverContext) {
+ free(pDisplayContext);
+ return NULL;
+ }
+
+ pDriverContext->native_dpy = (void *)native_dpy;
+ pDriverContext->x11_screen = XDefaultScreen(native_dpy);
+ pDriverContext->display_type = VA_DISPLAY_X11;
+
+ dri_state = calloc(1, sizeof(*dri_state));
+ if (!dri_state) {
+ free(pDisplayContext);
+ free(pDriverContext);
+ return NULL;
+ }
+
+ pDriverContext->drm_state = dri_state;
+
+ return (VADisplay)pDisplayContext;
}