frontends/va: Fix locking in vlVaBeginPicture
The assert in vlVaSetSurfaceContext would very rarely fail because the mutex was already unlocked when calling this function from vlVaBeginPicture. Keep the lock until returning from vlVaBeginPicture, as that's what other functions are already doing. Reviewed-by: Leo Liu <leo.liu@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25823>
This commit is contained in:
@@ -97,9 +97,10 @@ vlVaBeginPicture(VADriverContextP ctx, VAContextID context_id, VASurfaceID rende
|
||||
}
|
||||
|
||||
surf = handle_table_get(drv->htab, render_target);
|
||||
mtx_unlock(&drv->mutex);
|
||||
if (!surf || !surf->buffer)
|
||||
if (!surf || !surf->buffer) {
|
||||
mtx_unlock(&drv->mutex);
|
||||
return VA_STATUS_ERROR_INVALID_SURFACE;
|
||||
}
|
||||
|
||||
context->target_id = render_target;
|
||||
vlVaSetSurfaceContext(drv, surf, context);
|
||||
@@ -116,8 +117,10 @@ vlVaBeginPicture(VADriverContextP ctx, VAContextID context_id, VASurfaceID rende
|
||||
context->target->buffer_format != PIPE_FORMAT_R8G8B8X8_UNORM &&
|
||||
context->target->buffer_format != PIPE_FORMAT_NV12 &&
|
||||
context->target->buffer_format != PIPE_FORMAT_P010 &&
|
||||
context->target->buffer_format != PIPE_FORMAT_P016)
|
||||
context->target->buffer_format != PIPE_FORMAT_P016) {
|
||||
mtx_unlock(&drv->mutex);
|
||||
return VA_STATUS_ERROR_UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
if (drv->pipe->screen->get_video_param(drv->pipe->screen,
|
||||
PIPE_VIDEO_PROFILE_UNKNOWN,
|
||||
@@ -126,12 +129,14 @@ vlVaBeginPicture(VADriverContextP ctx, VAContextID context_id, VASurfaceID rende
|
||||
context->needs_begin_frame = true;
|
||||
}
|
||||
|
||||
mtx_unlock(&drv->mutex);
|
||||
return VA_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
if (context->decoder->entrypoint != PIPE_VIDEO_ENTRYPOINT_ENCODE)
|
||||
context->needs_begin_frame = true;
|
||||
|
||||
mtx_unlock(&drv->mutex);
|
||||
return VA_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user