summaryrefslogtreecommitdiff
path: root/xvmc/intel_xvmc.c
diff options
context:
space:
mode:
Diffstat (limited to 'xvmc/intel_xvmc.c')
-rw-r--r--xvmc/intel_xvmc.c42
1 files changed, 22 insertions, 20 deletions
diff --git a/xvmc/intel_xvmc.c b/xvmc/intel_xvmc.c
index 1d7b6e20..ff13d03c 100644
--- a/xvmc/intel_xvmc.c
+++ b/xvmc/intel_xvmc.c
@@ -408,21 +408,18 @@ _X_EXPORT Status XvMCCreateSurface(Display * display, XvMCContext * context,
surface->privData = calloc(1, sizeof(struct intel_xvmc_surface));
- if (!(intel_surf = surface->privData)) {
- PPTHREAD_MUTEX_UNLOCK();
- return BadAlloc;
- }
+ if (!(intel_surf = surface->privData))
+ goto out_xvmc;
intel_surf->bo = drm_intel_bo_alloc(xvmc_driver->bufmgr,
"surface",
intel_ctx->surface_bo_size,
GTT_PAGE_SIZE);
- if (!intel_surf->bo) {
- free(intel_surf);
- return BadAlloc;
- }
+ if (!intel_surf->bo)
+ goto out_surf;
- drm_intel_bo_disable_reuse(intel_surf->bo);
+ if (drm_intel_bo_flink(intel_surf->bo, &intel_surf->gem_handle))
+ goto out_bo;
intel_surf = surface->privData;
intel_surf->context = context;
@@ -433,12 +430,18 @@ _X_EXPORT Status XvMCCreateSurface(Display * display, XvMCContext * context,
surface->width, surface->height);
if (!intel_surf->image) {
XVMC_ERR("Can't create XvImage for surface\n");
- free(intel_surf);
- _xvmc_destroy_surface(display, surface);
- return BadAlloc;
+ goto out_bo;
}
return Success;
+
+out_bo:
+ drm_intel_bo_unreference(intel_surf->bo);
+out_surf:
+ free(intel_surf);
+out_xvmc:
+ _xvmc_destroy_surface(display, surface);
+ return BadAlloc;
}
/*
@@ -632,7 +635,6 @@ _X_EXPORT Status XvMCPutSurface(Display * display, XvMCSurface * surface,
unsigned short destw, unsigned short desth,
int flags)
{
- Status ret = Success;
XvMCContext *context;
intel_xvmc_surface_ptr intel_surf;
@@ -640,8 +642,11 @@ _X_EXPORT Status XvMCPutSurface(Display * display, XvMCSurface * surface,
return XvMCBadSurface;
intel_surf = surface->privData;
+ if (!intel_surf)
+ return XvMCBadSurface;
+
context = intel_surf->context;
- if (!context || !intel_surf)
+ if (!context)
return XvMCBadSurface;
if (intel_surf->gc_init == FALSE) {
@@ -653,12 +658,9 @@ _X_EXPORT Status XvMCPutSurface(Display * display, XvMCSurface * surface,
}
intel_surf->last_draw = draw;
- drm_intel_bo_flink(intel_surf->bo, &intel_surf->gem_handle);
-
- ret = XvPutImage(display, context->port, draw, intel_surf->gc,
- intel_surf->image, srcx, srcy, srcw, srch, destx,
- desty, destw, desth);
- return ret;
+ return XvPutImage(display, context->port, draw, intel_surf->gc,
+ intel_surf->image, srcx, srcy, srcw, srch, destx,
+ desty, destw, desth);
}
/*