Commit 278fd016 authored by Laurent Aimar's avatar Laurent Aimar Committed by Rémi Duraffort

Used VA_INVALID_ID when appropriate.

(cherry picked from commit 3683cc99da0a39bca72d14a17682ffeacee7652b)
Signed-off-by: default avatarRémi Duraffort <ivoire@videolan.org>
parent 53d746d7
...@@ -128,6 +128,8 @@ static int Open( vlc_va_vaapi_t *p_va, int i_codec_id ) ...@@ -128,6 +128,8 @@ static int Open( vlc_va_vaapi_t *p_va, int i_codec_id )
/* */ /* */
memset( p_va, 0, sizeof(*p_va) ); memset( p_va, 0, sizeof(*p_va) );
p_va->i_config_id = VA_INVALID_ID;
p_va->i_context_id = VA_INVALID_ID;
/* Create a VA display */ /* Create a VA display */
p_va->p_display_x11 = XOpenDisplay(NULL); p_va->p_display_x11 = XOpenDisplay(NULL);
...@@ -155,7 +157,7 @@ static int Open( vlc_va_vaapi_t *p_va, int i_codec_id ) ...@@ -155,7 +157,7 @@ static int Open( vlc_va_vaapi_t *p_va, int i_codec_id )
if( vaCreateConfig( p_va->p_display, if( vaCreateConfig( p_va->p_display,
i_profile, VAEntrypointVLD, &attrib, 1, &p_va->i_config_id ) ) i_profile, VAEntrypointVLD, &attrib, 1, &p_va->i_config_id ) )
{ {
p_va->i_config_id = 0; p_va->i_config_id = VA_INVALID_ID;
goto error; goto error;
} }
...@@ -179,7 +181,7 @@ static void DestroySurfaces( vlc_va_vaapi_t *p_va ) ...@@ -179,7 +181,7 @@ static void DestroySurfaces( vlc_va_vaapi_t *p_va )
vaDestroyImage( p_va->p_display, p_va->image.image_id ); vaDestroyImage( p_va->p_display, p_va->image.image_id );
} }
if( p_va->i_context_id ) if( p_va->i_context_id != VA_INVALID_ID )
vaDestroyContext( p_va->p_display, p_va->i_context_id ); vaDestroyContext( p_va->p_display, p_va->i_context_id );
for( int i = 0; i < p_va->i_surface_count && p_va->p_surface; i++ ) for( int i = 0; i < p_va->i_surface_count && p_va->p_surface; i++ )
...@@ -193,7 +195,7 @@ static void DestroySurfaces( vlc_va_vaapi_t *p_va ) ...@@ -193,7 +195,7 @@ static void DestroySurfaces( vlc_va_vaapi_t *p_va )
/* */ /* */
p_va->image.image_id = VA_INVALID_SURFACE; p_va->image.image_id = VA_INVALID_SURFACE;
p_va->i_context_id = 0; p_va->i_context_id = VA_INVALID_ID;
p_va->p_surface = NULL; p_va->p_surface = NULL;
p_va->i_surface_width = 0; p_va->i_surface_width = 0;
p_va->i_surface_height = 0; p_va->i_surface_height = 0;
...@@ -208,6 +210,7 @@ static int CreateSurfaces( vlc_va_vaapi_t *p_va, void **pp_hw_ctx, vlc_fourcc_t ...@@ -208,6 +210,7 @@ static int CreateSurfaces( vlc_va_vaapi_t *p_va, void **pp_hw_ctx, vlc_fourcc_t
if( !p_va->p_surface ) if( !p_va->p_surface )
return VLC_EGENERIC; return VLC_EGENERIC;
p_va->image.image_id = VA_INVALID_SURFACE; p_va->image.image_id = VA_INVALID_SURFACE;
p_va->i_context_id = VA_INVALID_ID;
/* Create surfaces */ /* Create surfaces */
VASurfaceID pi_surface_id[p_va->i_surface_count]; VASurfaceID pi_surface_id[p_va->i_surface_count];
...@@ -233,7 +236,7 @@ static int CreateSurfaces( vlc_va_vaapi_t *p_va, void **pp_hw_ctx, vlc_fourcc_t ...@@ -233,7 +236,7 @@ static int CreateSurfaces( vlc_va_vaapi_t *p_va, void **pp_hw_ctx, vlc_fourcc_t
i_width, i_height, VA_PROGRESSIVE, i_width, i_height, VA_PROGRESSIVE,
pi_surface_id, p_va->i_surface_count, &p_va->i_context_id ) ) pi_surface_id, p_va->i_surface_count, &p_va->i_context_id ) )
{ {
p_va->i_context_id = 0; p_va->i_context_id = VA_INVALID_ID;
goto error; goto error;
} }
...@@ -453,7 +456,7 @@ static void Close( vlc_va_vaapi_t *p_va ) ...@@ -453,7 +456,7 @@ static void Close( vlc_va_vaapi_t *p_va )
if( p_va->i_surface_width || p_va->i_surface_height ) if( p_va->i_surface_width || p_va->i_surface_height )
DestroySurfaces( p_va ); DestroySurfaces( p_va );
if( p_va->i_config_id ) if( p_va->i_config_id != VA_INVALID_ID )
vaDestroyConfig( p_va->p_display, p_va->i_config_id ); vaDestroyConfig( p_va->p_display, p_va->i_config_id );
if( p_va->p_display ) if( p_va->p_display )
vaTerminate( p_va->p_display ); vaTerminate( p_va->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