Commit 97e7b030 authored by Jean-Paul Saman's avatar Jean-Paul Saman

VAAPI: vaQuerySurfaceStatus() is totally unreliable.

The first time befor a surface is used it will return VASurfaceReady.
However whenever it has been used it status is ALWAYS VASurfaceRendering,
therefor it is unusable as a guard against selecting a surface that is
being used for rendering or displaying.
parent e3d44222
...@@ -289,7 +289,8 @@ static void destroy_surfaces( vlc_va_conn_t *conn ) ...@@ -289,7 +289,8 @@ static void destroy_surfaces( vlc_va_conn_t *conn )
abort(); abort();
} }
surface->i_refcount --; if( surface->i_refcount > 0 )
surface->i_refcount --;
assert(surface->i_refcount == 0); assert(surface->i_refcount == 0);
vaDestroySurfaces( conn->p_display, &surface->i_id, 1 ); vaDestroySurfaces( conn->p_display, &surface->i_id, 1 );
...@@ -310,25 +311,18 @@ static vlc_va_surface_t *get_surface(vlc_va_conn_t *conn) ...@@ -310,25 +311,18 @@ static vlc_va_surface_t *get_surface(vlc_va_conn_t *conn)
assert( conn->pool.count > 0 ); assert( conn->pool.count > 0 );
assert( conn->pool.p_surfaces ); assert( conn->pool.p_surfaces );
unsigned int next = conn->pool.current; unsigned int next = (conn->pool.current + 1) % conn->pool.count;
unsigned int tries = 0; unsigned int tries = 0;
while (tries < conn->pool.count) while(tries < conn->pool.count)
{ {
VAStatus status;
VASurfaceStatus ready;
vlc_va_surface_t *surface; vlc_va_surface_t *surface;
surface = &conn->pool.p_surfaces[next]; surface = &conn->pool.p_surfaces[next];
vlc_mutex_lock(&surface->lock); vlc_mutex_lock(&surface->lock);
VASurfaceID id = surface->i_id; if (surface->i_refcount == 0)
status = vaQuerySurfaceStatus(conn->p_display, id, &ready);
if ((status == VA_STATUS_SUCCESS) &&
(ready == VASurfaceReady) &&
(surface->i_refcount == 0))
{ {
surface->i_refcount++; surface->i_refcount++;
conn->pool.current = (next + 1) % conn->pool.count; conn->pool.current = next;
vlc_mutex_unlock(&surface->lock); vlc_mutex_unlock(&surface->lock);
return surface; return surface;
} }
...@@ -351,16 +345,8 @@ static void release_surface(vlc_va_conn_t *conn, vlc_va_surface_t *surface) ...@@ -351,16 +345,8 @@ static void release_surface(vlc_va_conn_t *conn, vlc_va_surface_t *surface)
if (surface->i_refcount == 0) if (surface->i_refcount == 0)
abort(); abort();
VAStatus status; surface->i_refcount--;
VASurfaceStatus ready; assert(surface->i_refcount == 0);
VASurfaceID id = surface->i_id;
status = vaQuerySurfaceStatus(conn->p_display, id, &ready);
if ((status == VA_STATUS_SUCCESS) &&
(ready == VASurfaceReady))
{
surface->i_refcount--;
assert(surface->i_refcount == 0);
}
vlc_mutex_unlock(&surface->lock); vlc_mutex_unlock(&surface->lock);
} }
......
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