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

codec/avcodec/va.{c,h}: Initialize/terminate libva only once.

Initialize/terminate libva only once. VAAPI calls are now being used by
2 modules which only have interaction with each other through vlc core.
Both modules (codec and vout) can be initiated independently they should
not call vaIntialize (or vaTerminate) one after each other (or simultanously).
parent 2d6cf618
......@@ -47,7 +47,7 @@
#ifdef HAVE_AVCODEC_VAAPI
/* Global VAAPI connection state */
static vlc_va_conn_t vlc_va_conn = { 0, 0, 0, 0 };
static vlc_va_conn_t vlc_va_conn = { NULL, 0, 0, 0, 0 };
static vlc_va_conn_t *vlc_va_get_conn( void )
{
......@@ -76,6 +76,7 @@ int vlc_va_Initialize( vlc_va_conn_t *conn, const char *display_name )
if( vaInitialize(conn->p_display, &conn->i_version_major, &conn->i_version_minor) )
goto error;
conn->i_ref_count++;
b_va_inited = true;
return VLC_SUCCESS;
......@@ -83,4 +84,19 @@ error:
return VLC_EGENERIC;
}
void vlc_va_Terminate( vlc_va_conn_t *conn )
{
conn->i_ref_count--;
if (conn->i_ref_count <= 0)
{
if( conn->p_display )
vaTerminate( conn->p_display );
if( conn->p_display_x11 )
XCloseDisplay( conn->p_display_x11 );
conn->p_display = 0;
conn->p_display_x11 = NULL;
}
}
#endif
......@@ -69,9 +69,11 @@ struct vlc_va_conn_t
VADisplay p_display;
int i_version_major;
int i_version_minor;
int i_ref_count; /* for internal use only */
};
int vlc_va_Initialize(vlc_va_conn_t *conn, const char *display_name);
void vlc_va_Terminate(vlc_va_conn_t *conn);
#endif
#endif
......
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