Commit 3fdefc74 authored by Jean-Paul Saman's avatar Jean-Paul Saman

VAAPI: cleanup global vlc_va_conn_t declaration.

Remove duplicated initialization and use explicit structure initialization.
parent 42b32b9d
......@@ -47,8 +47,6 @@
#ifdef HAVE_AVCODEC_VAAPI
/* Global VAAPI connection state */
static vlc_va_conn_t vlc_va_conn = { 0, 0, 0, 0, NULL, NULL, 0, NULL, NULL, NULL };
static vlc_mutex_t vlc_va_conn_lock = VLC_STATIC_MUTEX;
static void vlc_va_lock(void)
......@@ -116,6 +114,24 @@ static void vlc_va_destroy_surfaces( vlc_va_conn_t *conn )
conn->p_surface_ids = NULL;
}
/* Global VAAPI connection state */
static vlc_va_conn_t vlc_va_conn = {
.p_display = 0,
/* libva version */
.i_version_major = 0,
.i_version_minor = 0,
/* ref counting */
.i_ref_count = 0,
/* locking functions */
.lock = vlc_va_lock,
.unlock = vlc_va_unlock,
/* surfaces - NOTE: must be called with lock held */
.i_surface_count = 0,
.p_surface_ids = NULL,
.create_surfaces = vlc_va_create_surfaces,
.destroy_surfaces = vlc_va_destroy_surfaces,
};
/* */
vlc_va_conn_t *vlc_va_get_conn( void )
{
......@@ -124,54 +140,46 @@ vlc_va_conn_t *vlc_va_get_conn( void )
vlc_va_conn_t *vlc_va_Initialize( Display *display )
{
vlc_mutex_lock(&vlc_va_conn_lock);
vlc_mutex_lock( &vlc_va_conn_lock );
/* connect global to caller */
vlc_va_conn_t *conn = vlc_va_get_conn();
assert(conn);
if (conn->i_ref_count > 0)
assert( conn );
if( conn->i_ref_count > 0 )
{
conn->i_ref_count++;
vlc_mutex_unlock(&vlc_va_conn_lock);
vlc_mutex_unlock( &vlc_va_conn_lock );
return conn;
}
conn->lock = vlc_va_lock;
conn->unlock = vlc_va_unlock;
conn->i_surface_count = 0;
conn->p_surface_ids = NULL;
conn->create_surfaces = vlc_va_create_surfaces;
conn->destroy_surfaces = vlc_va_destroy_surfaces;
/* Create a VA display */
conn->p_display = vaGetDisplay(display);
if( !conn->p_display )
goto error;
if( vaInitialize(conn->p_display, &conn->i_version_major, &conn->i_version_minor) )
if( vaInitialize( conn->p_display, &conn->i_version_major, &conn->i_version_minor ) )
goto error;
conn->i_ref_count++;
vlc_mutex_unlock(&vlc_va_conn_lock);
vlc_mutex_unlock( &vlc_va_conn_lock );
return conn;
error:
vlc_mutex_unlock(&vlc_va_conn_lock);
vlc_mutex_unlock( &vlc_va_conn_lock );
return NULL;
}
void vlc_va_Terminate( vlc_va_conn_t *conn )
{
assert(conn);
assert( conn );
conn->i_ref_count--;
if (conn->i_ref_count > 0)
if( conn->i_ref_count > 0 )
return;
assert(conn->i_ref_count == 0);
assert(conn->i_surface_count == 0);
assert(conn->p_surface_ids == NULL);
assert( conn->i_ref_count == 0 );
assert( conn->i_surface_count == 0 );
assert( conn->p_surface_ids == NULL );
if( conn->p_display )
vaTerminate( conn->p_display );
......
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