Commit 42be4519 authored by Jean-Paul Saman's avatar Jean-Paul Saman

src/xvba_video.c: rewrite sync_surface()

parent 140ae52b
......@@ -135,6 +135,7 @@ destroy_surface(xvba_driver_data_t *driver_data, object_surface_p obj_surface)
}
// Query surface status
// NOTE: also used for images
int
query_surface_status(
xvba_driver_data_t *driver_data,
......@@ -145,21 +146,22 @@ query_surface_status(
{
int status;
if (surface_status)
*surface_status = VASurfaceReady;
if (!surface_status)
abort(); /* coding error */
*surface_status = 0;
if (!obj_surface)
return 0;
abort(); /* coding error */
switch (obj_surface->va_surface_status) {
case VASurfaceRendering: /* Rendering (XvBA level) */
ASSERT(obj_surface->used_for_decoding);
if (!obj_context)
return 0;
goto ok; /* Can be called with obj_context = NULL */
if (!obj_context->xvba_decoder)
return 0;
abort(); /* coding error */
if (!obj_surface->xvba_surface)
return 0;
goto ok;;
status = xvba_sync_surface(
obj_context->xvba_decoder,
obj_surface->xvba_surface,
......@@ -177,11 +179,22 @@ query_surface_status(
if (status == XVBA_COMPLETED)
obj_surface->va_surface_status = VASurfaceReady;
break;
default:
/* NOTE: va_surface_status could be 0 or VASurfaceSkipped
* in both cases it is safe to be used. */
if ((obj_surface->va_surface_status == 0) ||
(obj_surface->va_surface_status == VASurfaceSkipped)) {
goto ok;
}
break;
}
if (surface_status)
*surface_status = obj_surface->va_surface_status;
return 0;
ok: /* State is safe to continue surface is not used for decoding */
*surface_status = VASurfaceReady;
return 0;
}
// Synchronize surface
......@@ -195,9 +208,10 @@ sync_surface(
VASurfaceStatus surface_status;
int status;
while ((status = query_surface_status(driver_data, obj_context, obj_surface, &surface_status)) == 0 &&
surface_status != VASurfaceReady)
do {
status = query_surface_status(driver_data, obj_context, obj_surface, &surface_status);
delay_usec(XVBA_SYNC_DELAY);
} while(surface_status != VASurfaceReady && status != 0);
return status;
}
......
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