Commit 2360d9c9 authored by Jean-Paul Saman's avatar Jean-Paul Saman

VAAPI XCB: properly lock on releasing libva connection.

vlc_va_Terminate() forgot to lock when releasing the libva connection. This
openned a window for a race condition.
parent 44f116c8
...@@ -171,24 +171,27 @@ error: ...@@ -171,24 +171,27 @@ error:
void vlc_va_Terminate( vlc_va_conn_t *conn ) void vlc_va_Terminate( vlc_va_conn_t *conn )
{ {
vlc_mutex_lock( &vlc_va_conn_lock );
assert( conn ); assert( conn );
assert( conn->i_ref_count > 0 );
conn->i_ref_count--; conn->i_ref_count--;
if( conn->i_ref_count > 0 ) if( conn->i_ref_count == 0 )
return; {
assert( conn->i_surface_count == 0 );
assert( conn->i_ref_count == 0 ); assert( conn->p_surface_ids == NULL );
assert( conn->i_surface_count == 0 );
assert( conn->p_surface_ids == NULL );
if( conn->p_display ) assert( conn->p_display );
vaTerminate( conn->p_display ); vaTerminate( conn->p_display );
/* Reset values */ /* Reset values */
conn->p_display = 0; conn->p_display = 0;
conn->i_version_major = conn->i_version_minor = 0; conn->i_version_major = conn->i_version_minor = 0;
conn->i_ref_count = 0; conn->i_ref_count = 0;
conn = NULL; conn = NULL;
}
vlc_mutex_unlock( &vlc_va_conn_lock );
} }
#endif #endif
...@@ -361,7 +361,9 @@ void CloseVaapiX11(vlc_object_t *obj) ...@@ -361,7 +361,9 @@ void CloseVaapiX11(vlc_object_t *obj)
if (sys->vaconn) if (sys->vaconn)
{ {
sys->vaconn->lock();
sys->vaconn->destroy_surfaces(sys->vaconn); sys->vaconn->destroy_surfaces(sys->vaconn);
sys->vaconn->unlock();
vlc_va_Terminate(sys->vaconn); vlc_va_Terminate(sys->vaconn);
} }
......
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