Commit c6abcea1 authored by Jean-Paul Saman's avatar Jean-Paul Saman

VAAPI: Sync surfaces before destroying them.

Sync surfaces before they are destroyed. The surfaces can be used from more then
one thread context. Therefor make sure that all operations on the surface have
been performed. Then destroy the surface.
parent 99dc2c3a
...@@ -106,6 +106,20 @@ static void vlc_va_destroy_surfaces( vlc_va_conn_t *conn ) ...@@ -106,6 +106,20 @@ static void vlc_va_destroy_surfaces( vlc_va_conn_t *conn )
if( conn->i_ref_count > 1 ) if( conn->i_ref_count > 1 )
return; return;
for( int i = 0; i < conn->i_surface_count; i++ )
{
VASurfaceID i_id = conn->p_surface_ids[i];
#if VA_CHECK_VERSION(0,31,0)
if( vaSyncSurface( conn->p_display, i_id ) )
#else
if( vaSyncSurface( conn->p_display, conn->i_context_id, i_id ) )
#endif
{
fprintf(stderr, "Fatal error reboot your system\n" );
abort();
}
}
if( conn->p_surface_ids != NULL ) if( conn->p_surface_ids != NULL )
vaDestroySurfaces( conn->p_display, conn->p_surface_ids, vaDestroySurfaces( conn->p_display, conn->p_surface_ids,
conn->i_surface_count ); conn->i_surface_count );
...@@ -128,6 +142,7 @@ static vlc_va_conn_t vlc_va_conn = { ...@@ -128,6 +142,7 @@ static vlc_va_conn_t vlc_va_conn = {
/* surfaces - NOTE: must be called with lock held */ /* surfaces - NOTE: must be called with lock held */
.i_surface_count = 0, .i_surface_count = 0,
.p_surface_ids = NULL, .p_surface_ids = NULL,
.i_context_id = VA_INVALID_ID,
.create_surfaces = vlc_va_create_surfaces, .create_surfaces = vlc_va_create_surfaces,
.destroy_surfaces = vlc_va_destroy_surfaces, .destroy_surfaces = vlc_va_destroy_surfaces,
}; };
......
...@@ -280,6 +280,7 @@ static int CreateDecodingContext( vlc_va_vaapi_t *p_va, void **pp_hw_ctx, vlc_fo ...@@ -280,6 +280,7 @@ static int CreateDecodingContext( vlc_va_vaapi_t *p_va, void **pp_hw_ctx, vlc_fo
p_va->i_context_id = VA_INVALID_ID; p_va->i_context_id = VA_INVALID_ID;
goto error; goto error;
} }
p_va->conn->i_context_id = p_va->i_context_id;
/* Find and create a supported image chroma */ /* Find and create a supported image chroma */
int i_fmt_count = vaMaxNumImageFormats( p_va->conn->p_display ); int i_fmt_count = vaMaxNumImageFormats( p_va->conn->p_display );
...@@ -574,6 +575,7 @@ static void Close( vlc_va_vaapi_t *p_va ) ...@@ -574,6 +575,7 @@ static void Close( vlc_va_vaapi_t *p_va )
vlc_va_Terminate( p_va->conn ); vlc_va_Terminate( p_va->conn );
} }
if( p_va->display ) if( p_va->display )
XCloseDisplay( p_va->display ); XCloseDisplay( p_va->display );
} }
......
...@@ -43,6 +43,7 @@ struct vlc_va_conn_t ...@@ -43,6 +43,7 @@ struct vlc_va_conn_t
/* NOTE: must be called with lock held */ /* NOTE: must be called with lock held */
int i_surface_count; int i_surface_count;
VASurfaceID *p_surface_ids; VASurfaceID *p_surface_ids;
VAContextID i_context_id;
VASurfaceID *(*create_surfaces)(vlc_va_conn_t *conn, const int width, const int height, VASurfaceID *(*create_surfaces)(vlc_va_conn_t *conn, const int width, const int height,
const int fourcc, const int num); const int fourcc, const int num);
......
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