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